i am having a problem with animations in my game using flashpunk

fire ball

this is one of the animations that are causing problems in the game. The animation looks like that. The actual entity however with the animation on it looks like this
enter image description here
but without the tiled background

the code i am using is this


import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;
import net.flashpunk.FP;
import net.flashpunk.graphics.Spritemap;

public class Fireball extends Entity
    public var angle:int = FP.angle(Player.playerX,Player.playerY,FP.world.mouseX, FP.world.mouseY);
    [Embed(source = 'Images/fire ball.png')] private const FIREBALLANIME:Class;
    protected var animatedSprite:Spritemap = new Spritemap(FIREBALLANIME,128,128);

    public function Fireball()

    animatedSprite = new Spritemap(FIREBALLANIME, 16, 16);
    graphic = animatedSprite;
    animatedSprite.add("defaultfire", [0, 1, 2, 3], 24);
    x = Player.playerX;
    y = Player.playerY;
    override public function update():void




i turned the png's into an animation using texture packer. The ide i am using is FlashDevelop. I used pyxel edit to make the actual art.

  • \$\begingroup\$ Posting code in the question is preferred to using a pastebin. Just try to format it correctly; you're missing some whitespace on the leading and closing braces. No big deal there. Just to be clear, it looks like you're trying to load and use a spritesheet, presumably to iterate through its cells one at a time. And right now you're seeing a static section from the source image, right? \$\endgroup\$ – Seth Battin Mar 6 '16 at 5:16
  • \$\begingroup\$ sorry i actually was going to use paste bin but i am new to the site so it did not let me post a link \$\endgroup\$ – Wavegunner232 Mar 6 '16 at 16:28
  • \$\begingroup\$ you are correct i am using a spritesheet. however the animation is running it just looks completely wrong and mutated \$\endgroup\$ – Wavegunner232 Mar 6 '16 at 16:42

I assume that with texture packer you mean TexturePacker, right?

The default settings in TexturePacker assume that you use a data file wich describes the positions of the sprites in the sheet. Why? Because this allows a whole bunch of nice tricks like removing transparency, packing different sized sprites and more.

Your code does not use such a data file - for this you have to change a bunch of the settings:

  1. Layout > Algorithm = Basic
  2. Layout > SortBy = Name
  3. Layout > ShowAdvanced > Detect Identical Sprites = Off
  4. Sprites > Trim Mode = None

Also make sure that your sprites all have the same size and the animation is aligned within the sprite frames.

  • \$\begingroup\$ i did this and now it looks like nothing the actual object has lost its actual animation imgur.com/V10iyNr this is the new sprite sheet \$\endgroup\$ – Wavegunner232 Mar 6 '16 at 16:44
  • \$\begingroup\$ Your sprites don't seem to be 16x16, are they? You have to adjust the Spritemap contructor to match the frame size: Spritemap(source:*, frameWidth:uint = 0, frameHeight:uint = 0, callback:Function = null) \$\endgroup\$ – Andreas Löw Mar 6 '16 at 21:11
  • \$\begingroup\$ ok so i changed it to 32 by 32 and the animation is there but same problem it is still completly weird and looks exactly like it did in the screenshot on the question \$\endgroup\$ – Wavegunner232 Mar 6 '16 at 21:52
  • \$\begingroup\$ solved the problem by changing it to 64 by 64 big help THANKS :) !!! \$\endgroup\$ – Wavegunner232 Mar 6 '16 at 21:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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