Flash worksheets - Exercise 9
Exercise 9 Create the Game Logic (1)
Objective - get mcGunship moving with left and right arrow keys, spacebar will fire mcBullet and mcBullet will fly
- study the sample code and annotate for moving mcGunship
- alter the sample code and test for different speed.
- study the code for adding bullet, alter code for firing a bullet when spacebar pressed.
- study the code for bullet flying. Alter thecode for your bullet movement
- when finished, annotate your code in detail for your portfolio.
Exercise 10 Create the Game Logic (2)
Objective - layout an array of mcAliens and make them move left/right/downward
- determine how many aliens per row and how many rows to start with.
- create the aliens and place them in a matrix, and in an array
- alter the sampel code to suit your own need
- when finished, annotate your code in detail for your portfolio.
Exercise 11 Create the Game Logic (3)
Objective - make mcAlienSpaceship fly, use hitTestObject() to check collisions and scores
Exercise 12 Create the Game Logic (4)
Objective - displays, lives and try again
Exercise 13 Create the Game Logic (5)
Objective - level up
Exercise 15 Create the Game Logic (6)
Objective - System testing and debugging
Exercise 14 Publish the Game
Exercise 15 Write the User Manual and Technical Manual
The main methods of adding children and controlling their depth are:
- theContainer.addChild(childName) -- If theContainer has no children initially and you use the method repeatedly for a number of children, they are added on consecutive increasing depths 0,1,2,..., theContainer.numChildren-1. If theContainer is not empty, the method will add the child on the next available depth.
- theContainer.addChildAt(childName, depth) -- The method will add a child at the specified depth. The depth must be between 0 and theContainer.numChildren. Other children will be relocated to new depths to make room for the new child without leaving any depth unoccupied.
- theContainer.setChildIndex(existingChildName, depth) -- The method will relocate an existing child to the specified depth. The depth must be between 0 and theContainer.numChildren-1. Other children will be relocated. See the Flash movie above.
- theContainer.swapChildren(existingChildName, existingChildName) -- The name of the method is self-explanatory. See the Flash movie above.
- theContainer.swapChildrenAt(occupiedDepth, occupiedDepth) -- The name of the method is self-explanatory. See the Flash movie above.
- theContainer.getChildIndex(existingChildName) -- Returns the depth of a given child. Often used to reshuffle children. See the Flash movie above.
- theContainer.removeChild(existingChildName) -- Removes a given child. Other children move to fill all the depths.
- theContainer.removeChildAt(existingChildName,occupiedDepth) -- Removes a child from a given depth. Other children move to fill all the depths.
These are the basic methods, there are more of them. The main thing to remember is the all the children are always placed on depths 0,1,..,theContainer.numChildren-1. Thus the line:
theContainer.setChildIndex(existingChildName, theContainer.numChildren-1);
places the said child in front of all other children.
On the next two pages of this tutorial, we will show a 3D and a drag and drop examples where depths control is important.