[Embed(source="../../assets/graphics/blabla.png")]
private const HERO:Class;
[Embed(source="../../assets/graphics/blabla_powerup.png")]
private const HERO_2:Class;
public var spritemap:Spritemap = new Spritemap(HERO, 20, 20);
later on
graphic = spritemap
standard code. however, I want a powerup to change the spritemap into another one, as I find it easier to simply change spritemaps instead of adding animations to one big-ass spritemap, so I tried (in the update function)
if (changeSpritemap)
{
if (HeroStats.powerup_active) spritemap = new Spritemap(HERO_2, 20, 20);
else spritemap = new Spritemap(HERO, 20, 20);
changeSpritemap = false;
graphic = spritemap;
}
changeSpritemap is set to true whenever you pick up a powerup, and the spritemap seems to change just fine, but the animation is frozen, it doesn’t change or update in any way after it has been set to the powerup file…
I assume it’s because I haven’t set
spritemap.add("stand", [0], 0, false);
spritemap.add("run", [10, 11, 12, 13, 14, 15], 15, true);
spritemap.add("jump", [40, 41, 42, 43], 10, true);
spritemap.add("glide", [20, 21], 15, true); etc
for the “new” spritemap, but why would hey get removed when the spritemap simply changes the file? is there any way to keep these animations?
to explain why I would want to use different pngs for different sets of animations, is because I already have a ton of animations set (stand, run, jump, glide and maybe 40 more), if I expand the spritemap with the powerup ones, then I will have a total of 80 animations to keep track of… instead of only having 40 as before with different files