VG:Enemy Patrol

From MyProjectFun
Jump to: navigation, search

Q: How do you make an enemy move back and forth when the enemy come into viewport?

For a sprite centered at 300 on the x-axis that walks right 32 pixels before turning left, do this:

This.Sprite.Position.X = 300 + 32 * (float)Math.Sin(PatrolTimer);

Note that you need a public static int PatrolTimer that is incremented in the level's main behavior.

Personal tools
Namespaces
Variants
Actions
Navigation
Engineering
Game Design
Multimedia Production
VG Programming
Downloads
Toolbox