Instantly share code, notes, and snippets.

Embed
What would you like to do?
11.10 Add the Game Won scene to the game
#FantomX_UsePhysics = True
Import fantomX
Import character
Import projectile
Import custom_engine
Class Game Extends App
Field engine:ftEngine
Field play_layer:ftLayer
Field play_scene:ftScene
Field game_over_scene:ftScene
Field game_over_layer:ftLayer
Field next_level_scene:ftScene
Field next_level_layer:ftLayer
' Add the game won scene and its layer
Field game_won_scene:ftScene
Field game_won_layer:ftLayer
'...................
Method OnCreate()
'.........................
BuildGameOverScene(font)
BuildNextLevelScene(font)
' does what you would expect
BuildGameWonScene(font)
'.....................
End
'........................
' Method to Build the Game Won scene
Method BuildGameWonScene(font:ftFont)
game_won_scene = engine.CreateScene()
game_won_layer = engine.CreateLayer()
game_won_scene.AddLayer(game_won_layer)
engine.SetDefaultLayer(game_won_layer)
Local game_won_text:ftObject = engine.CreateText(font, "YOU BEAT THE GAME",
engine.GetCanvasWidth()/2 - 75, engine.GetCanvasHeight()/2 - 50, engine.taTopLeft)
Local game_won_instruction:ftObject = engine.CreateText(font, "Press ENTER to Play Again",
engine.GetCanvasWidth()/4, engine.GetCanvasHeight()/2 + 50, engine.taTopLeft)
game_won_scene.SetActive(False)
End
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment