Hi. I have a fireball class that is added whenever a mage is firing.
package
{
import net.flashpunk.Entity;
import net.flashpunk.Graphic;
import net.flashpunk.graphics.Image;
import net.flashpunk.Mask;
import flash.geom.Point;
import Math;
import net.flashpunk.graphics.Spritemap;
public class Fireball extends Entity
{
[Embed(source = "assets/Fireball.png")] private const FIREBALL:Class;
public var sprFireball:Spritemap = new Spritemap(FIREBALL, 96, 56);
private var graphicfx:Image;
private var fireBallSpeed:Number = 14;
public function Fireball(x:Number=0, y:Number=0)
{
super(x, y);
layer = 1;
graphicfx = new Spritemap(FIREBALL);
graphic = sprFireball;
sprFireball.add("flying", [9, 10, 11, 12, 13, 14, 15, 16, 17], 20, true);
graphicfx.angle = Math.atan2((Hero.yPos - y), (Hero.xPos - x)) * 180/ Math.PI + 90;
}
override public function update():void
{
sprFireball.play("flying")
x -= Math.sin(graphicfx.angle / -180 * Math.PI) * (fireBallSpeed);
y -= Math.cos(graphicfx.angle /-180*Math.PI)*(fireBallSpeed);
}
}
}
The thing is, the graphic itself always looks non-rotated, even if the direction it’s travelling at is correct. Can anyone point me in the right direction?