Last active
November 6, 2016 23:32
-
-
Save codetravis/415086eedcf0e1cb69abfed64b340262 to your computer and use it in GitHub Desktop.
5.3 OnUpdate and OnRender Function Setup
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
#FantomX_UsePhysics = True | |
Import fantomX | |
Class Game Extends App | |
Field engine:ftEngine | |
Field default_layer:ftLayer | |
Field default_scene:ftScene | |
Method OnCreate:Int() | |
engine = New ftEngine | |
default_scene = engine.GetDefaultScene() | |
default_layer = engine.GetDefaultLayer() | |
Return 0 | |
End | |
Method OnUpdate:Int() | |
Local time_delta:Float = Float(engine.CalcDeltaTime())/60.0 | |
engine.Update(time_delta) | |
Return 0 | |
End | |
Method OnRender:Int() | |
engine.Clear(255, 0, 0) | |
engine.SetColor(0, 70, 70) | |
engine.GetCanvas().DrawText("Last Touch: " + engine.GetTouchX() + ", " + engine.GetTouchY(), | |
engine.GetLocalX(10), engine.GetLocalY(10)) | |
engine.RenderFlush() | |
Return 0 | |
End | |
End | |
Function Main() | |
New Game() | |
End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment