Last active
February 3, 2017 15:14
-
-
Save codetravis/92ac8713406834f758ce5c8f1c4f8f23 to your computer and use it in GitHub Desktop.
13.2 Load a sprite atlas and pull the player animation from it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class Game Extends App | |
'...................... | |
Field current_level:Int | |
' add field to hold new sprite sheet | |
Field game_sprite_atlas:ftSpriteAtlas | |
'....................... | |
Method OnCreate() | |
Self.engine = New CustomEngine | |
play_scene = engine.GetDefaultScene() | |
play_layer = engine.GetDefaultLayer() | |
play_scene.AddLayer(play_layer) | |
'Load the sprite sheet before creating the player | |
LoadGameSprites() | |
CreatePlayer() | |
'................ | |
End | |
' load the image into a sprite atlas | |
Method LoadGameSprites() | |
game_sprite_atlas = New ftSpriteAtlas | |
game_sprite_atlas.Load("tutorial_game_sprite_sheet.png", "tutorial_game_sprite_sheet.txt") | |
End | |
'........................ | |
Method CreatePlayer() | |
' load player sprite from sprite atlas | |
Local box:ftObject = engine.CreateAnimImage(game_sprite_atlas.GetImage("player_submarine_anim"), 0, 0, | |
128, game_sprite_atlas.GetImageHeight("player_submarine_anim"), 3, engine.GetCanvasWidth()/2, engine.GetCanvasHeight()/2) | |
box.SetMaxSpeed(20.0) | |
box.SetMinSpeed(-20.0) | |
box.SetColGroup(PLAYER_GROUP) | |
box.SetColType(Self.engine.ctBox) | |
box.SetText("PLAYER") | |
Local projectile_type:ProjectileType = New ProjectileType() | |
Self.player = New Character(box, projectile_type, 0, 3, "PLAYER") | |
End | |
'.................. | |
End | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment