I have a simple question, I’m trying to make an huge game for Windows Phone, but I still have a important bottleneck/issue/bad performance.
I’ve used the mango profiler, but I have seen no problem, infact it’s using only 10% cpu on my phone.
Let me show you the 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 Draw, where map is a 20×15 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 seems that the DRAW is TOO slow for the UPDATE, or kinda of.
For Example:
1) I drag the screen on the right, very slowly -> the map texture is correctly moving on the right
2) I drag the screen on the right, then on the left, quite fast -> the map texture is correctly moving on the right, but has a little lag when moving on the left, like it’s still moving on the right..
3) I drag the screen circularly making a circle in 1 second -> well, the map needs 3 seconds to make a move circularly..
What I’m doing wrong??
Should I show you a youtube video??
Thanks you very much!!
Luca
FIXED!
this was so stupid..
it may happen that we have multiple touch in the same time before the draw, so we have to put a WHILE instead of IF on
then it will be
now it works like a charm!!!
I hope that this will be helpful for people who may have the same problem