Cloning/Copying/Duplicating Objects - (Clone)
Why? How? 1. Copying/Duplicating Objects While Designing Your GameOnce you have an object setup (size, name, color, skinned with an image, etc), you can easily duplicate it by holding down the "Ctrl" key (the control-key) and using the mouse - drag off new copies from the original. Then, if you need to, rename the copies.
Manually - After you have your object (button, card, etc) setup, you can clone it in the message box:
Alternatively, you can copy images by holding down the "Ctrl" or "Cmd" key and drag off a new copy. Then rename the copy to a new name of it's own
2. Creating More Objects Inside of Your Game You can create objects inside the game. As the game goes on, you can add more and more enemies to make it harder. Have them multiply and make the game get harder as it goes along. Suppose, you decide to generate enemies at random. It would make sense to write a handler to do it, and call that handler at random times.
The following is a sample of code that you might use:
global y
on makeEnemy
clone button "EnemyX"
set the name of the last button to ("enemy" & y)
add 1 to y
set the loc of last button to random(400),random(400)
set the visible of the last button to true
end makeEnemy
where: We assume that you have a sample enemy button called "EnemyX" off the screen that you will use to make copies from We use the variable "y" as a counter to keep track of the number of enemies we have created We have it appear at a random location (assuming our page is 400 pixels wide and 400 pixels high)
3. Creating More Objects by Drag and Drop (pulling them off the original)
You can create new ones by dragging them off the original
global myLoc on mouseDown grab me put the loc of me into myLoc clone me set the name of me to ("b" & y) set the loc of image "Tower" to myLoc end mouseDown
or
global y,x on mouseDown grab me clone me //clone btn "box" set the name of me to ("b" & y)" //set the loc of btn "box" to the loc of btn ("box" & y) add 1 to y //grab me end mouseDown
|
|