public void AddAnimation(string animName, SpriteBase sprite) { // sync sprite's position to this MultiAnimSprites' SpriteBase spriteCopy = new SpriteBase(sprite); spriteCopy.Position = m_vecPos; m_SpriteAnims.Add(animName, spriteCopy); }
public SpriteBase( SpriteBase o ) { this.m_vecPos = o.Position; this.m_vecOrigin = o.m_vecOrigin; this.m_playbackOptions = o.AnimationOptions; this.m_texBase = o.m_texBase; this.m_fScale = o.m_fScale; this.m_fRotation = o.m_fRotation; this.m_iCurrFrame = o.m_iCurrFrame; this.m_iMaxFrames = o.m_iMaxFrames; this.m_iFrameWidth = o.m_iFrameWidth; this.m_fFrameTime = o.m_fFrameTime; this.m_fTimeAccumulator = o.m_fTimeAccumulator; this.m_frameRect = o.m_frameRect; this.m_AABBs = o.m_AABBs; this.basicEffect = o.basicEffect; this.vertices = o.vertices; this.m_bDisplayAABBs = o.m_bDisplayAABBs; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>("calibri"); // TODO: use this.Content to load your game content here // Pointer to Graphics Device pDevice = graphics.GraphicsDevice; SpriteBase slimeCrouch = new SpriteBase(new Vector2(300, 100), 85, 2.0f, pDevice); SpriteBase slimeDeath = new SpriteBase(new Vector2(300, 200), 85, 2.0f, pDevice); SpriteBase slimeWalk = new SpriteBase(new Vector2(300, 300), 85, 2.0f, pDevice); SpriteBase slimeIdle = new SpriteBase(new Vector2(300, 400), 85, 0.5f, pDevice); slimeCrouch.LoadContent(Content, "slimesheet-crouch", OriginPos.TOP_LEFT); slimeDeath.LoadContent(Content, "slimesheet-death", OriginPos.TOP_LEFT); slimeWalk.LoadContent(Content, "slimesheet", OriginPos.TOP_LEFT); slimeIdle.LoadContent(Content, "slimesheet-idle", OriginPos.TOP_LEFT); slimeCrouch.DisplayAABBs = true; slimeDeath.DisplayAABBs = true; slimeWalk.DisplayAABBs = true; slimeIdle.DisplayAABBs = true; slimeCrouch.AnimationOptions = PlaybackOptions.Reverse | PlaybackOptions.Once; slimeDeath.AnimationOptions = PlaybackOptions.Once; multiAnimTest = new MultiAnimSprite(new Vector2(100, pDevice.PresentationParameters.BackBufferHeight - 100)); multiAnimTest.AddAnimation("IDLE", slimeIdle); multiAnimTest.AddAnimation("WALK", slimeWalk); multiAnimTest.AddAnimation("CROUCH", slimeCrouch); multiAnimTest.AddAnimation("DEATH", slimeDeath); multiAnimTest.DisplayAABBs = true; multiAnimTest.PlayAnimation("IDLE", null); gameObjects.Add(slimeCrouch); gameObjects.Add(slimeDeath); gameObjects.Add(slimeWalk); gameObjects.Add(slimeIdle); gameObjects.Add(multiAnimTest); }