Nice tip, I’ll use that for now! thanks
PS: I tried using getFrame() as you typed, but it didn’t seem to work.
if (sprHero.currentAnim == "run")
{
trace("running")
if (sprHero.getFrame() == 0) wepHotspotY = 85; trace("0");
if (sprHero.getFrame() == 1) wepHotspotY = 80; trace("1");
if (sprHero.getFrame() == 2) wepHotspotY = 75; trace("2");
if (sprHero.getFrame() == 3) wepHotspotY = 70; trace("3");
if (sprHero.getFrame() == 4) wepHotspotY = 70; trace("4");
if (sprHero.getFrame() == 5) wepHotspotY = 70; trace("5");
if (sprHero.getFrame() == 6) wepHotspotY = 70; trace("6");
if (sprHero.getFrame() == 7) wepHotspotY = 80; trace("7");
if (sprHero.getFrame() == 8) wepHotspotY = 85; trace("8");
}
It traces 0 through 8 on every frame whilst he is running. The running animation has 9 different frames itself.
I also tried changing it into this:
if (sprHero.currentAnim == "run")
{
if (sprHero.index == 0) wepHotspotY = 85; trace("0");
if (sprHero.index == 1) wepHotspotY = 80; trace("1");
if (sprHero.index == 2) wepHotspotY = 75; trace("2");
if (sprHero.index == 3) wepHotspotY = 70; trace("3");
if (sprHero.index == 4) wepHotspotY = 70; trace("4");
if (sprHero.index == 5) wepHotspotY = 70; trace("5");
if (sprHero.index == 6) wepHotspotY = 70; trace("6");
if (sprHero.index == 7) wepHotspotY = 80; trace("7");
if (sprHero.index == 8) wepHotspotY = 85; trace("8");
}
but that didn’t work. Which is weird, since I have an enemy who has his own punching animation and only if that punching animation has passed frame 6, then the hit will register.
if (impCollision)
{
if (invincibilityCounter == 0)
{
if (impCollision.sprImp.currentAnim == "attack")
{
if (impCollision.sprImp.index >= 6)
{
var damageTaken:Number = Imp.impStrength * armorReduction;
var xLocation:Number = x + this.width / 2 - 10;
var a:Number = x + this.width / 2;
var b:Number = Math.floor(Math.random() * (1 + y + 10 - y)) + y;
hp -= damageTaken;
invincibilityCountDown = true;
FP.world.add(new DamageShower(a, b, damageTaken, "0xFFFFFF"));
}
}
}
}
That seems to work, but not the whole hotspot thing!