Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

8 years ago by roger

Hi!

I have loaded some images in my game and I would like to rotate them.
Anyone knows how to rotate or flip an image?

Thanks!

8 years ago by alexandre

I think that the current version of Impact (1.18a) only lets you rotate Entity instances, and indirectly so: just set their animation to the desired rotation angle, e.g.,

update: function()
{
    this.currentAnim.angle = 45;
    parent.update();
}

8 years ago by dominic

You can create Animation instances without having an Entity, so the easiest way to have rotations and flipping is to wrap your Image in an Animation.

If you don't want to do that for whatever reason, look at the source for lib/impact/animation.js how it's done there and use the canvas methods directly.

8 years ago by yatayata

note you have to specify x and y separately for flips

this.currentAnim.flip.x = true;

http://impactjs.com/documentation/class-reference/animation#flip-x-flip-y
Page 1 of 1
« first « previous next › last »