Setting an angle around an imagepoint.

Discussion and feedback on Construct 2

Post » Thu Aug 30, 2012 11:54 pm

Is it possible to set an angle of a sprite around an image point?

I have a 32x32 sprite with the origin top-left as I want to snap it to a 32x32 grid, and at the start of the game it can be rotated to one of these angles; 0,90,180,270.

I know how to rotate "choose(....)" but it rotates it around the origin at the top left, I want it to rotate around its imagepoint which is in the center. Is there a way?

Edit: spellingNickydude2012-08-30 23:55:05
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Fri Aug 31, 2012 12:22 am

You could either leave the origin in the centre and have it snap to a 16x16 grid


or set it's position alongside rotating it like:
set angle to 90
set x to self.x+self.width

but of course a different position would be needed for each angle.


If you need them to rotate more than once, so it works regardless of their current angle, you could have an imagepoint in each corner.
So for rotating 90 degrees:
set position to self.imagepoint(TopRight)
set angle to self.angle+90

and for rotating 180 degrees
set position to self.imagepoint(BottomRight)
set angle to self.angle+180

etc

ps: this should have been posted in the 'how do i' forum
B
28
S
8
G
1
Posts: 469
Reputation: 4,683


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 16 guests