Alice Community  

Go Back   Alice Community > General Discussion > Questions and Comments

Reply
 
Thread Tools Display Modes
"While" function ?
Old
Laur07
Junior Member
 
Status: Offline
Posts: 11
Join Date: Jun 2011
Default "While" function ? - 06-20-2011, 03:38 PM

One of my methods in my project consists of a condition :Create a method called "fishJump". This method should take one fish object as a parameter and make that fish jump up out of the water and back in, at random speeds, and move a little away from the camera after each jump. It should continue to do this until either the fish is at least 10m away from the camera, or all 5 fish have been caught (use numCaught variable).

I used a "While" condition for this and made the fish jump infinity times but then i guess because of the "infinity" the rest of my project doesnt work after this ? Because i have another step after but it doesnt even acknowledge it....Am i doing this right ?
   
Reply With Quote
Old
beachbum111111
Senior Member
 
beachbum111111's Avatar
 
Status: Offline
Posts: 852
Join Date: Feb 2010
Location: e
Default 06-20-2011, 03:55 PM

Can you post your world?


"Don't lead me into temptation I can find it myself"
   
Reply With Quote
Old
Laur07
Junior Member
 
Status: Offline
Posts: 11
Join Date: Jun 2011
Default 06-20-2011, 04:00 PM

So its the "JumpFish" method that i guess is the problem ... and as i said i am not sure if i need to keep the infinity loop because nothing in my world method happens after but at the same time i need to keep my fish moving ...

thank you!!
Attached Files
File Type: a2w tutorial 11.a2w (456.7 KB, 23 views)
   
Reply With Quote
Old
Mr Kidnapper
Senior Member
 
Status: Offline
Posts: 442
Join Date: Feb 2011
Default 06-21-2011, 05:40 PM

What you have to do is make the Fish Jump method independent of the other methods. I assume you noticed the fish are still caught when the jump is in a loop, but the first method does not continue. Activate the FishJump method in another method, perhaps with a delay so that it at least looks like it happens at the same time. You could also use a variable. Say after the fishing boat says something
"Set Jumping Fish to True"
and an event "If Jumping Fish == True"
"During - For each item from FishList together:
JumpFish whichFish== item from FishList"
There is no FishList, but if you have not learned Lists and Arrays yet, it is a set of variables (Objects, strings, numbers, whatever.) so you don't have to make five 'When mouse is clicked on' events.
   
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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.