Adding sprite to scene object which stay at same offset regardless of rotation
Shri

Gio,

 

I'm trying to add a sprite to a 2D character in a top down shooter game.

The sprite woud be for example a health bar that should always be at the top left corner of the scene object (character).

However, when I rotate the scene object, then the health bar rotates with it.

Is there a way to disable the resetting of the offset position ?

 

I realize how wacky this request is because before I said, "when you rotate a scene object, the sprites attached to the scene object should rotate with it"

and you guys "fixed" this in a release of the engine.

 

I guess there are two cases:

If the attached sprite is say a slectable gun (so could be different sprites), in the players hand, you would want the gun to stay at the same relative offset based on the scene objects rotation.

 

If the attached sprite is say a health bar, you want it to stay a the same absolute offset regardless of the scene objects rotation.

 

 

I figure I can do this by using setSpriteOffset in the update routine of the scene object, but I was wondering if you had any thoughts on this.

 

thanks,

Shri

1 Comment
Gio

Hey Shri

 

First of all I will note (although you probably know this already) that you can set the rotation of individual sprites, not just scene objects, since Sprite has a setRotation method too. So it may be that, instead of rotating the scene object, you could just rotate the character sprite, if it's only one sprite that needs rotating.

 

I still think that the default behavior, when rotating a scene object, should be to rotate all the sprite offsets accordingly (as you had previously suggested). Having said that, I think it may also be a good idea to have an option to change that behavior. It would be just an extra flag that you set on the scene object to say that you don't want to rotate its sprite offsets.

 

I need to have a closer look to see what the performance implications would be, but I reckon it should be alright, and there's a good chance of us adding this for the next release.

Post a reply
Add Attachment
Submit Reply
Login to Reply