You can have other objects moving around the screen for you to collect (for points, to get to the next level, as a time challenge, ...) or avoid (like bombs, enemies, etc).
Ideas:- This could be for enemies, bombs, bullets, rewards, diamonds, shooting stars, etc
- Have an "enemy" move around the screen and you have to avoid it while going through a maze or just moving
- Make the path invisible and the object will move along the set path like magic:
- set the visible of <object><"name"> to false
- Have it occur at set intervals
You can use the "Random" function to generate random locations, use relative numbers (+ or -) to move it in regular paths, a list of points, a path or a number of other creative ways to keep it exciting
1. Moving Objects - the Move command
Objects are moved using the "move" command.
move <object> <name> to x,y
or with optional values:
- from <start loc>
- relative <+ or -> loc
- in <time - seconds, milliseconds, ticks>
- without waiting
Examples:
- move graphic "bomb" to 100,200
- move button "box" from 50,100 to 100,100
- move button "box" relative -25,0 (this moves it to the left 25 pixels, this is the same as "set the left of button "box" to the left of button "box" - 25)
- move button "box" to 100,100 in 5 secs
- move button "box" from 50,100 to 100,100 without waiting
- move the button "box" to the points of the graphic "rectangle"
- move the button "box" to the points of the graphic "path"
(Experiment and try these on your own)
Changing the Speed of the Objects
If you do not set the "time" in the "Move" command, you can change the speed of the object using the "moveSpeed" property. It can be any number between 0 to 65535 where the default is 200.
set the moveSpeed to 20
2. The Set Command
Using the Set command, you can also do it this way by adding this code to the object that you want to move:
on mouseMove
if the mouse is down then
if the mouse is down then
set the loc of me to the mouseLoc
end if
end mouseMove
3. Moving It To Set Points
You can program set point for it to go to by putting the points into a variable and using that variable in the move command
put 100,110 & return & 150,200 & return & 20,400 & return & 200,20 & return & 250,300 into PList
move button "box" to Plist
This will move the "box" to the points 100,110 150,200 20,400 200,20 250,300 which looks random
4. Moving it along a Set Path
You can "program" objects to move along a set path. You draw a path with the "Freehand" tool from the tools Palette (let's call it "path" - name it in the property inspector)
then you add the line (or a similar one):
- move the button "box" to the points of the graphic "path" in 5 secs
You can set the graphic "path" not visible which makes the game more interesting
4. Pausing for a few seconds - the Wait command
Sometimes you want to wait a few seconds before you have the player do something or another object move. For this you use the "Wait" command
for example:
wait 2 seconds
wait until the mouse is up
wait until the seconds < alarmTime
wait until the mouse is up
wait until the seconds < alarmTime
wait until the mouse is up
wait until the seconds < alarmTime
Generally if you are going to wait any extended time, you should add "with messages". This allows other events to occur in the background while you are waiting
or example:
wait 2 seconds with messages
wait until the mouse is up with messages
wait until the mouse is up with messages
wait until the mouse is up with messages
wait until the seconds < alarmTime with messages
(more to come...)
NEXT - Winning and Losing