Review Scene Management (Scene, Layer, Director) Sounds Menus Sprites & Actions
Scene a scene is composed of one or more layers app transitions take place through scenes typically one scene is used for the “playable” part of the game others scenes for: title, high scores, options
Layer a layer has the size of the device screen it defines appearance and behavior overlapping layers are typically given different functions (e.g, background, animation, menu)
Director the director takes care of moving between scenes runWithScene tells director to use that scene replaceScene replaces the running scene with another pauseScene puts the current scene on hold for another transitions allow for fancy scene change iphone.org/wiki/doku.php/prog_guide:lesson_3._m enus_and_scenes
Scene Management We added: A layer over the game layer showing game statistics A new scene to go to when the ship hits an asteroid
Sound Effects The library Cocosdenshion subproject of cocos2d-iphone targeted at game audio needs Sound effects can be loaded at application startup, so there's no delay during play
Sound Effects We added sound files to the 'Resources' Group (crtl-click → Add → Existing Files) Preload the.wav files in AsteroidsAppDelegate applicationDidFinishLaunching Play the.wav effects where needed iphone.org/wiki/doku.php/cocosdenshion:faq
Menus In the 'init' method of the AsteroidsScene Layer we: created the menu, and it's items describe how they would be displated on the page Attach the menu to the Layer We also need to declare the selector method to process user interactions
Sprites & Actions A sprite is a 2d image integrated into a larger scene (from Wikipedia) They can move and appear to be in active (e.g, blink) We will tie the sprit into the physics engine so that it can “interact” with other objects iphone.org/wiki/doku.php/prog_guide:sprites?s[]=s prites
Tie in with physics engine We subclassed CCSprite so that: The body and colission shape are created at init time The 'setPosition' method also tells the physics engine Delete the body and shape with the sprite is deallocated iphone.org/wiki/doku.php/prog_guide:sprites#how _to_subclass_sprites
Ideas of things to do Use more 'interesting' transitions between scenes Add sound when the flying saucer enters Have the flying saucer shoot missiles Remove the flying saucer when it hits an asteroid