/// <summary> /// Creates this scene. /// </summary> public TestScene() { ActiveCamera.Zoom = 3; Background = new GameObject(); Background.AddModule <TextureModule>().TextureID = "bg"; Add(Background); Sprite = new GameObject(); Sprite.WorldPosition.X = -1; Sprite.WorldPosition.Y = -14; AnimatedTextureModule anim = Sprite.AddModule <AnimatedTextureModule>(); anim.Prefix = "down_walk"; anim.numFrames = 2; anim.Playing = true; anim.FPS = 6; Sprite.AddModule <GRIDController>(); Sprite.AddModule <TextureHitArea>(); Add(Sprite); GameObject sprite2 = new GameObject(); sprite2.AddModule <TextureModule>().TextureID = "down_stand"; sprite2.WorldPosition.X = 55; Sprite.Add(sprite2); }
public override void Update(GameTime gT) { base.Update(gT); ActiveCamera.Position = Sprite.WorldPosition; AnimatedTextureModule anim = Sprite.GetModule <AnimatedTextureModule>(); bool pressed = false; KeyboardState kbs = Keyboard.GetState(); if (kbs.IsKeyDown(Keys.W)) { anim.Prefix = "up_walk"; pressed = true; } if (kbs.IsKeyDown(Keys.A)) { anim.Prefix = "left_walk"; pressed = true; } if (kbs.IsKeyDown(Keys.S)) { anim.Prefix = "down_walk"; pressed = true; } if (kbs.IsKeyDown(Keys.D)) { anim.Prefix = "right_walk"; pressed = true; } if (!pressed) { anim.Playing = false; anim.TextureID = "down_stand"; } else { anim.Playing = true; } }