Rotating an entity... problems


(John Andersson) #1

Okay, so I have an entity I want to use a pixelmask with. Now, I also want to rotate the entity. I know flashpunk can’t handle rotating hitboxes, but that’s okay, since I basically have a ball which is rolling. I needed to use centerorigin to set the rotation point at the middle of the ball, but now the hitbox is way off. I tried originX and originY, but it doesn’t work.


(Martí Angelats i Ribera) #2

Have a look here. I’m not sure if the last code works 'couse noone said so but the tread is about this.


(John Andersson) #3

Isn’t that about hitboxes? How do I make the ball rotate continuously?


(Martí Angelats i Ribera) #4

So you only want to rotate the graphic? If that’s so, what graphic are you using? (i mean the class, like Image, Stamp, etc.)


(John Andersson) #5

Yeah, I’m using a spritemap :slight_smile:


(Martí Angelats i Ribera) #6

I would do this:

In the contructor

private var sprite:Spritemap;
private var target:BitmapData;
private var renderer:Image;
//set spritemap

target = new BitmapData(size, size, true, 0);
renderer = new Image(target);
renderer.centerOrigin();
graphic = renderer;

and then in the render function:

override public function render():void
{
	target.fillRect(target.rect, 0);
	sprite.render(target, FP.zero, FP.zero);
	super.render();
}

All the modifications you do to renderer should modify the result as you spect.