How do I rotate the image content not the sprite itself?

Get help using Construct 2

Post » Tue Aug 02, 2016 8:14 pm

Hello.

My game engine is super complicated and I do not want to do the hassle to change the origin from top left to center, as the engine works better with the top left.

So I wonder if I can rotate the animation in center even if the origin is top-left?

The only I can think of is to create three more animations, identical but new orientation and change animation when change direction. But waste of space and cpu.

Any other ideas? :)
B
60
S
18
G
13
Posts: 449
Reputation: 10,811

Post » Tue Aug 02, 2016 9:07 pm

First thought that comes to my mind is use an imagepoint located at wherever you want the center.
Then, to rotate sprite:
-find position of imagepoint relative to layout via imagepointX(), imagepointY()
-now calculate the angle and distance from imagepoint to the origin of the sprite.
-set position of sprite to imagepointX+cos(calculatedAngle+rotationAmount)*calculatedDistance
-do the same for Y, but use Sin() instead of Cos()
-Now rotate the sprite by the same rotationAmount.
B
51
S
24
G
70
Posts: 1,196
Reputation: 41,370

Post » Tue Aug 02, 2016 9:21 pm

oh, I guess that would essentialy change the position of the origin.. so it might not be what you want.
You could maybe use a separate sprite object that doesn't rotate and is invisible, and then use your visible sprite to be allowed to rotate.
B
51
S
24
G
70
Posts: 1,196
Reputation: 41,370

Post » Tue Aug 02, 2016 10:47 pm

B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

Post » Tue Aug 02, 2016 11:22 pm

Thank you for replies!
B
60
S
18
G
13
Posts: 449
Reputation: 10,811


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], plinkie and 6 guests