public void AddAnimation(Animation animToAdd) { //Animation mayorMcCheese = (Animation)Helpah.Clone(animToAdd); //Object anmany = Helpah.Clone(animToAdd); //Animation mayorMcCheese = (Animation)anmany; animToAdd = Helpah.Clone(animToAdd).As<Animation>(); //animToAdd = (Animation)Helpah.Clone(animToAdd); //this.animations.Add(animToAdd); this.animations.Add(animToAdd); }
public Sprite(string spriteName, string fileName) { this.name = spriteName; AnimationFrame animFrame = new AnimationFrame(fileName, 0, 0); Animation anim = new Animation(); anim.SetName("Idle"); anim.AddFrame(animFrame); this.AddAnimation(anim); Sprite.loadedSprites.Add(this); }
//create a new sprite intended for a single frame animation public static Sprite singleFrame(string name, int width, int height, string frameLocation, int xOffset, int yOffset) { AnimationFrame animfrm = new AnimationFrame(frameLocation, xOffset, yOffset); Animation annie = new Animation(); annie.AddFrame(animfrm); Sprite newSprite = new Sprite(name); newSprite.Size = new Dimension(width, height); newSprite.AddAnimation(annie); return newSprite; }
//create a new animation from a single sprite sheet with each x and y location being a new frame //public static Animation fromSpriteSheet(string imgSheetLocation, List<int, int> framePositions) //public static Animation fromSpriteSheet(string imgSheetLocation, int frameWidth, int frameHeight, int[,] framePositions) public static Animation FromSpriteSheet(string imgSheetLocation, int frameWidth, int frameHeight, List<Point> framePositions) { Animation resultAnim = new Animation(); foreach (Point point in framePositions) { AnimationFrame animFrame = new AnimationFrame( imgSheetLocation, (int) Math.Round(point.x), (int) Math.Round(point.y)); resultAnim.AddFrame(animFrame); } return resultAnim; }
//sets the current animation to the provided one //returns true if the sprite has that animation //false if it doesn't public bool SetAnimation(string animationName) { foreach (Animation anim in this.animations) { if (anim.GetName() == animationName) { this.currentAnimation = anim; return true; } } return false; }
public Animation GetCurrentAnimation() { if (this.currentAnimation == null) { if (this.defaultAnimation == null) { this.defaultAnimation = this.animations[0]; } this.currentAnimation = this.defaultAnimation; } return this.currentAnimation; }
public static Animation SingleFrame(AnimationFrame frame) { Animation returnAnim = new Animation(); returnAnim.AddFrame(frame); return returnAnim; }