Rotate Picture in a certain angle.

KanaX

Just being a sleepy
Veteran
Joined
Apr 3, 2013
Messages
1,455
Reaction score
1,297
First Language
Broken English.
Primarily Uses
N/A
The Rotate Picture command rotates the picture indefinitely, until I give a second command for it to stop. I want a picture to rotate to a certain angle and then stop rotating. Is this possible?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
Don't know about pictures, but Sprites have an @angle attribute that can be used for rotation. You would have to use a script to manage it, though, and make sure to dispose it when it's no longer needed to avoid memory leaks.
 

KanaX

Just being a sleepy
Veteran
Joined
Apr 3, 2013
Messages
1,455
Reaction score
1,297
First Language
Broken English.
Primarily Uses
N/A
Pictures have it too. I tried to make some script calls but they didn't work.


EDIT: Ok, I actually solved it.

I created a conditional "screen.pictures[x].angle == y" and then I set the speed to 0.
For some stupid reason, the first time I replaced "y" with a negative value, which of course didn't work.

I'd like to thank lavra for pointing out the interesting fact that sprites can rotate too, something I plan to put to good use.
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
$test = Sprite.new$test.bitmap = Bitmap.new("Graphics/Battlers/Slime")$test.x = 100$test.y = 100$test.z = 1$test.angle = 270
This displays the Slime battler at position x = 100, y = 100 (in pixels, not tiles), rotated by 270°. z needs to be higher than 0 to be visible at all (Windows have z = 10 by default). On a later point you would have to call:

$test.dispose
to free up your memory.
 

J_C

Veteran
Veteran
Joined
Jan 21, 2015
Messages
192
Reaction score
45
First Language
Hungarian
Primarily Uses
N/A
Pictures have it too. I tried to make some script calls but they didn't work.


EDIT: Ok, I actually solved it.

I created a conditional "screen.pictures[x].angle == y" and then I set the speed to 0.
For some stupid reason, the first time I replaced "y" with a negative value, which of course didn't work.

I'd like to thank lavra for pointing out the interesting fact that sprites can rotate too, something I plan to put to good use.
Would you break this down for me step by step? I tried to replicate the script but it doesn't work.
 

KanaX

Just being a sleepy
Veteran
Joined
Apr 3, 2013
Messages
1,455
Reaction score
1,297
First Language
Broken English.
Primarily Uses
N/A
You want me to explain to you how the conditional for stopping the rotation works?
 

J_C

Veteran
Veteran
Joined
Jan 21, 2015
Messages
192
Reaction score
45
First Language
Hungarian
Primarily Uses
N/A
You want me to explain to you how the conditional for stopping the rotation works?
Yes, please, the condition and the script. I tried to use the scripts you and lavra mentioned in the topic, but to no avail.
 

KanaX

Just being a sleepy
Veteran
Joined
Apr 3, 2013
Messages
1,455
Reaction score
1,297
First Language
Broken English.
Primarily Uses
N/A
Sorry for the late reply.

It quite honestly has to do with how fast your picture is rotating and how often you check for its angle. If the picture rotates too fast, then Ace will not be able to "find" it in angle you want to.

1. A "patchwork" way to do it, is to give your conditional a margin of error. Have this script call inside a conditional:
 


screen.pictures[1].angle >= 200 && screen.pictures[1].angle <= 210


If you put that little script in your conditional, then instead of checking for a single angle, Ace will be checking for an angle that's bigger than 200 but smaller than 210. That way, if you check every second frame, even if Ace misses you initial value (200) it will still stop somewhere relatively close, with the largest possible diversion being 10 degrees (210). The larger that gap is, the easiest it is to stop the picture for higher speeds.

I tested it for a -5 speed, I checked every 2 frames and it worked. (Test project, no scripts).





But if your picture rotates much faster than that (double digit fast), then that won't be enough.


2. A second way I came up with for stopping, is an easing. Have this inside a script call command:


screen.pictures[1].rotate((x - screen.pictures[1].angle)/180)


x is the angle you want your picture to stop at.


This script call will make your picture get progressively slower, the closer it gets to the angle you want it to stop at.







If you want it to slow down faster then do this:
 


screen.pictures[1].rotate(((x - screen.pictures[1].angle)/180)*y)


y is a constant value of your choice. The bigger it is, the faster the picture will be reaching 0 velocity. If y is high enough, you can make the stop seem instantaneous.







DISCLAIMER: I'm not well acquainted with scripting yet, so there might be some less convoluted / more sophisticated ways to help you out. This is what I could figure out within my current knowledge and strength. With a little imagination, it has worked well for me. If someone more experienced would like to add something more, please feel free to.
 
Last edited by a moderator:
  • Like
Reactions: J_C

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,854
Messages
1,016,998
Members
137,562
Latest member
tamedeathman
Top