Gesture Free Game

I have a simple question, I am trying to make a huge game for Windows Phone, but I still have an important bottleneck / problem / poor performance.

I used a mango profiler, but I did not see any problems, imposed it using only 10% of the processor on my phone.

Let me show you this problem.

This is my update.

protected override void Update(GameTime gameTime) { if (TouchPanel.IsGestureAvailable) { var gs = TouchPanel.ReadGesture(); switch (gs.GestureType) { case GestureType.FreeDrag: Position += gs.Delta; break; } } base.Update(gameTime); } 

This is my drawing, where the map is 20x15 Texture2D

 protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(map, Position, null, Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 1f); spriteBatch.End(); base.Draw(gameTime); } 

The problem is that DRAW seems to be too slow for UPDATE or some sort of.

Example:

1) I drag the screen to the right, very slowly → the texture of the map moves correctly to the right

2) I drag the screen to the right and then to the left, pretty quickly → the texture of the map moves correctly to the right, but has a slight lag when moving to the left, as if it is still moving to the right ..

3) I drag the screen in a circular circle in 1 second → well, the map needs 3 seconds to make the movement circular.

What am I doing wrong?

Should I show you a YouTube video?

Thank you very much! Luke

+4
source share
1 answer

FIXED!

It was so stupid.

it may happen that before making a draw, we have a few touches, so we must put WHILE instead of IF on

 if (TouchPanel.IsGestureAvailable) 

then it will be

 while (TouchPanel.IsGestureAvailable) 

Now it works like a charm !!!

I hope this will be useful for people who may have the same problem.

+2
source

Source: https://habr.com/ru/post/1396648/


All Articles