Discord
Login
Community
DARK THEME

Is there any way to find the draw rotation

I want to draw a sprite rotated, and then reset the draw rotation. Is there any way to find out what the draw rotation is already set to?

local oldRot = findDrawRotation()
screen.setDrawRotation(newRot)
screen.drawSprite()
screen.setDrawRotation(oldRot)

To reset the draw rotation you just do screen.setDrawRotation(0)
But I suspect your question implies that the DrawRotation is already set to some value. In that case it is always a good idea to save the last value in its own variable. Then you just have to use that one to set it back.

Otherwise ... more details please =)

You are correct, although the problem is that I'm using this as part of a function in a library, and it might be irritating to the user if they had to set a variable whenever they want to change the draw rotation :/ For now I just reset it, and put a note saying that the draw rotation will be reset, but I was wondering if there was a way to get the rotation (maybe a hidden variable or something)

Must be somewhere, how else would it remember it for future draw operations. I guess @gilles will know. Might be hidden in the canvas maybe.

Hmmm, this is what happens in the runtime (some uneducated github digging ...)

 Screen.prototype.setDrawRotation = function(object_rotation) {
    this.object_rotation = object_rotation;
  };

I also noticed the the sprite.xxx.frames[x] object holds a parameter by the same name, but they don't seem to be 'connected'. I'll ask the all-knowing one =)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community