Create unlimited objects that have their own behaviors
Posted: Sat Dec 05, 2015 5:06 pm
Hello
i would want to know how create a number of object unlimited. Each object move independently one of the others. I do this but when i press a key for the second time. I have a rectangle in the middle of my screen besides the graphic oval "balle".
I want to do when i press on a key , a "ball" be created and move.
i would want to know how create a number of object unlimited. Each object move independently one of the others. I do this but when i press a key for the second time. I have a rectangle in the middle of my screen besides the graphic oval "balle".
I want to do when i press on a key , a "ball" be created and move.
Code: Select all
on keyDown k
if k is space then
Fire
end if
end keyDown
command Fire
create graphic "ball"
set the style of graphic "ball" to "oval"
set the width of graphic "ball" to 28; set the height of graphic "ball" to 12
set the opaque of graphic "ball" to true
set the backgroundColor of graphic "ball" to "red"
--set the location of graphic "ball" to ...
send "MoveBall" && "ball"
end Fire
command MoveBall graphicObject
set the location of graphic graphicObject to (the item 1 location of graphic graphicObject + 1), (the item 2 location of graphic graphicObject)
send "MoveBall graphicObject" to me in 2 milliseconds
end MoveBall