Rotating a sprite by its middle, not its origin

Get help using Construct 2

Post » Thu May 28, 2015 2:06 pm

Hi all, thanks for reading!

I have a boss sprite with an origin that's "bottom," and for its death animation only, I want it to rotate as if its origin was in its exact center. This way, it doesn't look like it's flipping out wildly in large circles, and instead should rotate smoothly in place.

My thoughts on this are:

- Create an invisible block that spawns when the boss dies. Pin the boss to the block upon death and just have the block rotate in place.
- Somehow change the sprite origin with events, which I don't believe can be done.
- Some other action commands that can achieve the same goal, such as "rotate around point X"
B
24
S
6
G
1
Posts: 47
Reputation: 1,894

Post » Thu May 28, 2015 2:26 pm

You can have more than one origin point.
B
13
S
5
G
4
Posts: 139
Reputation: 2,586

Post » Thu May 28, 2015 2:31 pm

More than one origin point, huh? Is this different than right clicking in the image points dialogue box and choosing "add image point?"

I knew you could have multiple image points but I only ever had one origin point. For example, if I choose to do "every tick, rotate BossSprite by 12 pixels," it automatically chooses the origin (or perhaps it just chooses the 0th image point?) I guess my question here, then, is that since there's no way to use the "rotate clockwise" action to say "every tick, rotate by 12 pixels based on image point 1," that there must be another way to do it.

I'm using the invisible block idea I mentioned above, and while it works, I'm sure there's a simpler way.
B
24
S
6
G
1
Posts: 47
Reputation: 1,894

Post » Thu May 28, 2015 6:24 pm

Wouldn't it be simpler to keep the origin as the center and have another sprite for the death animation?
Or leave it as is and when you change to the death animation just move the sprite?

You can use a little math to rotate a sprite around any point if you wish to do that instead.
https://www.siggraph.org/education/mate ... 2drota.htm
global number centerx= 100
global number centery= 100
global number ang= 10

every tick
--- sprite: rotate ang degrees clockwise
---- sprite: set position to ( (self.x-centerx)*cos(ang)-(self.y-centery)*sin(ang)+centerx, (self.x-centerx)*sin(ang)+(self.y-centery)*cos(ang)+centery )
B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Tue Jun 02, 2015 12:21 am

Message: Mallets is not yet permitted to post plain text URLS (300 rep required). 1 URLS removed. Why?
R0J0hound wrote:Wouldn't it be simpler to keep the origin as the center and have another sprite for the death animation?
Or leave it as is and when you change to the death animation just move the sprite?

You can use a little math to rotate a sprite around any point if you wish to do that instead.global number centerx= 100
global number centery= 100
global number ang= 10

every tick
--- sprite: rotate ang degrees clockwise
---- sprite: set position to ( (self.x-centerx)*cos(ang)-(self.y-centery)*sin(ang)+centerx, (self.x-centerx)*sin(ang)+(self.y-centery)*cos(ang)+centery )


Oh, wow. This would do it, huh? I never would have figured this out in a million years, so thank you so much for the explanation!!
B
24
S
6
G
1
Posts: 47
Reputation: 1,894

Post » Fri Dec 09, 2016 2:09 pm

Message: shubhamrathi9 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
R0J0hound wrote:Wouldn't it be simpler to keep the origin as the center and have another sprite for the death animation?
Or leave it as is and when you change to the death animation just move the sprite?

You can use a little math to rotate a sprite around any point if you wish to do that instead.
https://www.siggraph.org/education/mate ... 2drota.htm
global number centerx= 100
global number centery= 100
global number ang= 10

every tick
--- sprite: rotate ang degrees clockwise
---- sprite: set position to ( (self.x-centerx)*cos(ang)-(self.y-centery)*sin(ang)+centerx, (self.x-centerx)*sin(ang)+(self.y-centery)*cos(ang)+centery )


Sir,
I am very happy to find this post it helped me a lot , but this helped me to turn right using an imagepoint but it does not work for turning left and am having real trouble in setting up the equation for the same.
i thought making it negative would do it but nope!
Can you please please help me and post an equation for Left Rotation ?
It would be very helpful as i have spent all day on it and haven't go it working yet!
B
18
S
7
Posts: 104
Reputation: 1,691

Post » Fri Dec 09, 2016 2:48 pm

never mind sir! GOT IT! :)
B
18
S
7
Posts: 104
Reputation: 1,691


Return to How do I....?

Who is online

Users browsing this forum: GrogIsGood, Kyu and 52 guests