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
58
S
18
G
13
Posts: 447
Reputation: 10,740

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
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

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
47
S
22
G
65
Posts: 1,127
Reputation: 38,395

Post » Tue Aug 02, 2016 10:47 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Aug 02, 2016 11:22 pm

Thank you for replies!
B
58
S
18
G
13
Posts: 447
Reputation: 10,740


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 9 guests