Rapid press button to rotate picture

Howdy folks! 🙂 I'm tring to do a event which enable the player to rotate a picture by keep pressing a button. (30 degree/press or just continue rotating while the button is pressed down) But I can only manage to do one 30 degree rotation with the loop conditional branch detect button pressing, then I just can't figure out how to allow the player keep pressing while cause the picture to keep rotating. All my tries with double loops resulted in freeze.


Also another question, I managed to do a common event title manual and just skip the actully title of the game. It works fine until I have to go back to the manual. then it just goes back to the real title instead of my event one. So I'm wondering about how to make my way back to the event title manual instead of the actull manual.
Loop


Wait: 1 frame


If Button is Pressed


.. Set Switch #1 to ON


Else


.. Set Switch #1 to OFF


End


If Switch #1 is ON


.. If Switch #2 is OFF


.... Rotate Picture 15 deg


.. End


.. Set Switch #2 to ON


Else


.. If Switch #2 is ON


.... Rotate Picture 15 deg


.. End


.. Set Switch #2 to OFF


End


If (condition)


.. Break Loop


End


Repeat Above


Erase Event


This will keep rotating the picture 30 degrees for every time you press the button and release it.  Be VERY careful about placing and nesting branches exactly as I've shown above.  Holding the button down won't do anything (by design).  It will keep processing this, without a freeze, until (condition) is met.  You will probably want to have another Parallel Process event incrementing a variable every second so you can check how long you've been running this loop for (for use in the condition).  This event itself should also be Parallel Process, most likely, and should have a Page Condition (probably a switch) that won't be met until you're ready to start the rotate processing.


If you can't follow this, you will need to read some tutorials on eventing.  I think @Andar has some good ones in his signature.


The title manual sounds like a problem in a script you are using.
@Wavelength


I still can't get it to work, when the switch for this parallel event is turned on it just automaticly rotate 15 degree and no matter what I put it will not rotate further. At least it doesn't freeze like it used to do. Here are the screeenshots:


QQ图片20160807131146.png


QQ图片20160807131154.png


QQ图片20160807131158.png


No other events share these switches, the script I used is Hime Picture Wrapper
beornotbe, please avoid double posting, as it is against the forum rules. You can review our forum rules here. Thank you.


If you want to add something, simply edit your post.


There is no need to quote an entire post, which makes scrolling down the page slow.  Instead, if you want to make it clear who you are replying to, just use the convention @username at the beginning of your reply. 
@Wavelength


I still can't get it to work, when the switch for this parallel event is turned on it just automaticly rotate 15 degree and no matter what I put it will not rotate further. At least it doesn't freeze like it used to do. Here are the screeenshots:


...


No other events share these switches, the script I used is Hime Picture Wrapper



My bad - I actually mixed up the commands for setting Switch #2 (in your case Switch #50).  The first command should set it ON and the second should set it OFF - the idea is that right before restarting the loop it should be matching Switch #1 (46) so that in the next cycle it will only trigger the rotate if you change the value of Switch #1 again.  I have corrected my example above.


I tested this corrected version just now by creating the event using a sound effect rather than a picture rotation, for simplicity, and it worked perfectly.  (Also worth noting is that I used a different button besides the "B" symbol which has uses elsewhere in RPG Maker, like opening the menu.)  If it still doesn't work properly for you after making the correction, then try it with playing a Sound Effect instead of rotating a picture.  If the Sound Effect works properly, then Hime's script has a bug and you should report it at Hime Works.
@Wavelength


Thanks heaps, it does work on SE, but not with the script. I think the problem is the angles are not addable, they are all rotated from the position of the original image. So when I tried the above on images, it will only rotate 30 degree if I put two 30 degree rotation. So if I have the first command to rotate 15, second to rotate 30, what I would see is when I press and release the button, the image jumps to 30 degrees, and when I hold the button down, it jumps back to 15 degree.  In theory I could just do 30, 60, 90.....390 etc. to give it a illusion of rotate, but I really can't think of a way for it to work as it would need even more loops and conditions.


UPDATE😮K I figured out another way. Now hold the button will keep it rotating, release it will stop the image at the exact position. Thanks again for your help 🙂


UPDATE 2: After some testing, I found the condition for exit command doesn't seem to work. I put fade out and erase picture command under 'if button B is pressed'. Because this is a parallel event, I also disabled player movement and menu temporarily and hope to renable them via button press. However it doesn't seem to do any of these. I did try another key and it still doesn't fade out. And when I trigger the rotation loop again the picture just freeze. I tried to delete the erase event at the end of the command chain, the picture no longer freeze upon being triggered second time, however I still can't make the exit by button command work.


UPDATE 3: I figured out an alternative way to make it stop. Thx for the support!
You should be able to use variables instead.


Notes: Variable[001]: is a tracker for the amount of times the key has been pressed, we're gonna use this for the angle maths.


Label: Reset


Conditional Branch: Button Right is pressed


Control Variables[001]: + 1


Jump to Label: Update


End


Conditional Branch: Button Left is pressed


Control Variables[001]: - 1


Jump to Label: Update


End


Conditional Branch: Button B is pressed
Jump to Label: Confirm


End


Wait 1 Frames


Jump to Label Reset


Label: Update


Conditional Branch: Variable[001]: is greater or equal to 24


Control Variables[001]: = 0


End


Script: Rotate_pic(17, $game_variables[001] * 15, 1)


Wait X frames (Less frames = More sensibility)


Jump to Label: Reset


Label: Confirm


[Whatever else you need before ending the event]


Erase Event


In theory, every time you press a direction it should register an input and proceed to update the picture at an angle equal to the variable multiplied by 15 degrees and jump right back at the input detection. If nothing is pressed, it refreshes and wait for an input. When the player is done, pressing the B button will make the rest of the event execute itself before erasing itself.
@Saboera


It doesn't seem to do anything...Still, appreciate the help!

QQ图片20160808155058.png

QQ图片20160808155102.png
Pretty sure it's my own mistake.


The zero in $game_variables[011] is messing it up, my bad, replace that line with Script: rotate_pic(17, $game_variables[11] * 15, 1)


There's a mistake in my original event flow too, you need to add this after Label: Update


Conditional Branch: Variable[001]: is less than 0


Control Variables[001]: = 23


End


I'm not sure how the custom script you use work, never tried it, but I assumed (17 is the pic number, 15 is the angle and 1 is the rotating point? center or top left)


Also, you don't need else conditions in your event flow if you leave it blank and want to keep the event clean and you'll want to raise the wait frame after the ''update section to more than 1 frame, otherwise it would execute a full rotation in 0.4 sec.
@Saboera


Thx for the reply 🙂 Unfortunately the effect I want can not be achieved through this particular script. However I figured out an alternative way to do it and it worked. You can check my updates on this problem in my reply to wavelength. I will also record your way of handling this so I can try it out later on similar situation. Thx heaps!

Original thread: https://forums.rpgmakerweb.com/threads/rapid-press-button-to-rotate-picture.66413/