Rotating a sprite by its middle, not its origin

0 favourites
  • 7 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • 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"
  • You can have more than one origin point.

  • 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.

  • 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 )

  • 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!!

  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • never mind sir! GOT IT!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)