Hi! I'm making an app where I have falling items and the player catches it with a basket to show info about the items, but i have trouble with the falling blocks. I made 5 and in my codes they randomize position and fall all togethter at the same time. I want it to be like : for every image sprite --> do procedure ranpos --> wait for 3 seconds --> loop again. Can anyone help?
You need a 3 second Clock Timer that scans the list of all Sprite components, and takes the first invisible (.Visible = false) sprite and runs just that sprite through your launch procedure.
I assume you are giving each speed and direction at launch, so it can run at its own power?
I also assume you have an Edge Reached event to stop and mark invisible any sprite that reaches the edge or the basket?
yes, I am giving each speed and direction at launch and have an edge reached event to reset the item's Y position back to the top when it reaches the edge. I am not so sure about how to make the clock timer scan the list of all sprite components, is it ok if you give a code example? thanks so much for answering!
when screen.initialized
set spriteList to all the falling sprites.
for each sprite in spritelist{
set sprite visible to false
}
when clock1.timer
if(spriteList is not empty){
get item 1 from spriteList;
remove it from spritelist;
set its speed ,direction, x, y,picture...
set it visible to true
}
when any sprite.reach edge {
set its speed to 0
set its visible to false
add it to the spritelist
}
when bucket.collidewith{
if (other is in list spritelist){
set other visible to false
add other to list spritelist
do other stuff like score adding...
}
}
hi, thanks so much for your help!! but im a newbie and im not so sure about how to create a spritelist.I tried using initialize global but it cant take it out as a sprite, and i cant pull out something like set sprite visible, sorry for the trouble but I can't really understand!
but in your first post, you said this:
oh, sorry, i thought i needed to initialize a global before i do it, ill try it agian! thanks so much
better use a seperate list to store all the falling sprite, the falling sprites is not same as everysprites, at least the basket is not falling sprite.
and do not use for each loop in clock.timer.
read my pseudocode again carefully.
thank you so much!!! I got it!!!