Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Stopping an object and key press events?
Old
Eilis
Guest
 
Status:
Posts: n/a
Default Stopping an object and key press events? - 05-03-2011, 06:58 PM

I was assigned an exercise in which I have to make a figure skater skate in a circle and when 'S' or 'J' are pressed the skater spins or jumps. I've got the the skater skating in a smooth circle by infinitely looping her turning left and moving forward. For getting her to spin, I just set her to turn left 1 revolution when 'S' is pressed but since she's moving forward while spinning she just makes a little loop and the full circle shifts ever so slightly. A classmate suggested setting the skater's vehicle property to another object and having that object spin to move the skater then having the skater spin. It works really well and provides the smooth effect that my instructor wants but I feel kinda like it's cheating and would prefer to do it without another object. It's proving to be rather difficult. I was wondering if there was some way to use a while statement or something to loop the skating in a circle then when the 'S' key is pressed the skater stops momentarily and does the spinning animation then resumes skating. I can't seem to figure out any solutions and it's really bothering me. Apologies if this is hard to understand, I'm not that good at explaining myself.
   
Reply With Quote
Old
jediaction
Senior Member
 
jediaction's Avatar
 
Status: Offline
Posts: 5,064
Join Date: Jul 2009
Location: Bel Air, Maryland
Default 05-03-2011, 07:05 PM

Ok, I kind of lost you half way. Can you post the project and let me see it. Then rephrase what you want in one sentence?


Website: www.salokingames.com
FaceBook: www.facebook.com/SalokinGames
   
Reply With Quote
Old
Eilis
Guest
 
Status:
Posts: n/a
Default 05-03-2011, 07:18 PM

Currently the ice skater when pressing 'S' does a little loopy thing to spin, I need her to when 'S' is pressed to stop, spin in one place, then resume skating, or just spin in one place while moving.
Attached Files
File Type: a2w iceskater.a2w (3.23 MB, 14 views)
   
Reply With Quote
Old
jediaction
Senior Member
 
jediaction's Avatar
 
Status: Offline
Posts: 5,064
Join Date: Jul 2009
Location: Bel Air, Maryland
Default 05-03-2011, 08:26 PM

Ok, this is what you do.

Make the skate method where the skater moves forward in a if/else statement. When you press "S", change the variable that is being controlled in the if/else statement from 0 to 1(make sure it is a number variable). Have the if/else statement running in an infinite loop. When you press "S", whatever is in the else will run also. Make the variable change from 1 to 0. Then in the same section, add the animation for the skater spinning then after the animation, make the variable change to 1 again and because of the infinite loop, the program will read "if variable is == 1, then skater move forward (however many meters it is).

Did I lose you or did you get it? Basically it is If pressed, skater stop, then if let go, skater go, and this is controlled by 1 and 0


Website: www.salokingames.com
FaceBook: www.facebook.com/SalokinGames
   
Reply With Quote
Old
Eilis
Guest
 
Status:
Posts: n/a
Default 05-03-2011, 09:34 PM

Yeah, you lost me. How to make the variable change when pressing 'S'?
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2021, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.