I’m having trouble with static vars.
I have a spritemap in a hero class, and I have a separate gloves class.
I want to make it so that the gloves class plays an animation equal to the hero class. A.k.a one with the same name.
Hero:
[Embed(source = 'assets/Hero_Full.png')] private const HERO:Class;
public var sprHero:Spritemap = new Spritemap(HERO, 120, 136);
Gloves:
var heroAnimation:String = Hero.sprHeroIsntHere-HowDoIgetIt?
sprGloves.play(heroAnimation);
Of course, I can make sprHero a public static var, but if I do that, then I get this error:
“Access of undefined property HERO”.
I assume I can do something like this:
var heroCollide:Hero = Hero(collide("hero", x, y));
if (heroCollide != null)
{
_equipped = true;
spritemap.play(heroCollide.sprHero.currentAnim);
}
But I want the spritemap to play the same animation as sprHero even if it isn’t colliding!
This is very confusing. Thanks