Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.
public void Update(GameTime gameTime)
    {
        if (bActive && bMovingTowardsTarget)
        {
            if (!(v2Target == null))
            {
                // Get a vector pointing from the current location of the sprite
                // to the destination.
                Vector2 Delta = new Vector2(v2Target.X - asSprite.X, v2Target.Y - asSprite.Y);

                if (Delta.Length() > Speed)
                {
                    Delta.Normalize();
                    Delta *= Speed;
                    Position += Delta;
                }
                else
                {
                    if (v2Target == asSprite.Position)
                    {
                        if (bPathing)
                        {
                            if (queuePath.Count > 0)
                            {
                                v2Target = queuePath.Dequeue();
                                if (bLoopPath)
                                {
                                    queuePath.Enqueue(v2Target);
                                }
                            }
                            else
                            {
                                if (!(sEndPathAnimation == null))
                                {
                                    if (!(Sprite.CurrentAnimation == sEndPathAnimation))
                                    {
                                        Sprite.CurrentAnimation = sEndPathAnimation;
                                    }
                                }

                                if (bDeactivateAtEndOfPath)
                                {
                                    IsActive = false;
                                }

                                if (bHideAtEndOfPath)
                                {
                                    IsVisible = false;
                                }
                            }
                        }
                    }
                    else
                    {
                        asSprite.Position = v2Target;
                    }
                }
            }
        }
        if (bActive)
            asSprite.Update(gameTime);
    }

This is my update and

for (int i = 0; i < 50; i++)
        {
            float angle = (float)(i / 100.0 * Math.PI * 2);

            vertices[i].Position = new Vector3(200 + (float)Math.Cos(angle) * 100, 200 + (float)Math.Sin(angle) * 100, 0);
            Console.WriteLine(" vertices is :" +" ( +"+ vertices[i].Position.X + " , " + vertices[i].Position.Y + " )");
            vertices[i].Color = Color.Black;
        }
        vertices[49] = vertices[0];


for (int i = 0; i < 100; i++)

        {

   //  myTank.AddPathNode(new Vector2(vertices[i].Position.X, vertices[i].Position.Y));


        }

I don't know why but the sprite doesn't move smoothly here and doesn't follow on half circle here. I need you guys help here!

share|improve this question
4  
You can't just post a large section of code and ask how to 'do' something with it. – Austin Brunkhorst Jul 22 '12 at 8:59
Voting to close as too localized, as most of these types of questions are. – Byte56 Jul 22 '12 at 16:22

closed as too localized by Byte56, bummzack, Joe Wreschnig, Josh Petrie, Jonathan Hobbs Aug 22 '12 at 8:52

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

http://www.enchantedage.com/node/78 This should be along the same idea you are attempting in XNA.

If you are looking to follow a Bezier or control points I know Cocos2d has the CCBezierBy class. You can certainly lift the code and concepts from there too.

Here's an discussion that may help, http://stackoverflow.com/questions/9990443/rotating-a-sprite-on-a-bezier-curve-in-cocos2d

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.