I am developing a small game using Haxe and box2d. I am rescaling the player body which is a sphere, while the player is in contact with a particular object, but I am trying to scale the image as I scale the body.
public function new(w:Int, x:Int, y:Int)
{
super();
this.w = w;
this.x = x;
this.y = y;
var imgSprite = new Sprite();
imgSprite.addChild(new Bitmap(Assets.getBitmapData("img/ball.png")));
imgSprite.x = -w;
imgSprite.y = -w;
this.addChild(imgSprite);
this.alpha = .5;
contactList = new Array<B2Body>();
makeBody(w, x, y, 0);
}
public function resize(w:Int, x:Int, y:Int)
{
var tempAngle = this.body.getAngle();
Main.World.destroyBody(this.body);
makeBody(w, x, y, tempAngle);
}
There is nothing that I know of that is built in to easily scale images. How can I scale the bitmap alongside the body?