Browse Source

add some api docs for hxd.App (#320)

Dan Korostelev 7 years ago
parent
commit
b3ec1fb01f
1 changed files with 58 additions and 0 deletions
  1. 58 0
      hxd/App.hx

+ 58 - 0
hxd/App.hx

@@ -1,10 +1,36 @@
 package hxd;
 
+/**
+	Base class for a Heaps application.
+
+	This class contains code to set up a typical Heaps app,
+	including 3D and 2D scene, input, update and loops.
+
+	It's designed to be a base class for an application entry point,
+	and provides several methods for overriding, in which we can plug
+	custom code. See API documentation for more information.
+**/
 class App implements h3d.IDrawable {
 
+	/**
+		Rendering engine.
+	**/
 	public var engine(default,null) : h3d.Engine;
+
+	/**
+		Default 3D scene.
+	**/
 	public var s3d(default,null) : h3d.scene.Scene;
+
+	/**
+		Default 2D scene.
+	**/
 	public var s2d(default,null) : h2d.Scene;
+
+	/**
+		Input event listener collection.
+		Both 2D and 3D scenes are added to it by default.
+	**/
 	public var sevents(default,null) : hxd.SceneEvents;
 
 	public var wantedFPS(get, set) : Float;
@@ -28,6 +54,12 @@ class App implements h3d.IDrawable {
 	function get_wantedFPS() return hxd.Timer.wantedFPS;
 	function set_wantedFPS(fps) return hxd.Timer.wantedFPS = fps;
 
+	/**
+		Screen resize callback.
+
+		By default does nothing. Override this method to provide custom on-resize logic.
+	**/
+	@:dox(show)
 	function onResize() {
 	}
 
@@ -98,10 +130,27 @@ class App implements h3d.IDrawable {
 		sevents.dispose();
 	}
 
+	/**
+		Load assets asynchronously.
+
+		Called during application setup. By default immediately calls `onLoaded`.
+		Override this method to provide asynchronous asset loading logic.
+
+		@param onLoaded a callback that should be called by the overriden
+		                method when loading is complete
+	**/
+	@:dox(show)
 	function loadAssets( onLoaded ) {
 		onLoaded();
 	}
 
+	/**
+		Initialize application.
+
+		Called during application setup after `loadAssets` completed.
+		By default does nothing. Override this method to provide application initialization logic.
+	**/
+	@:dox(show)
 	function init() {
 	}
 
@@ -116,6 +165,15 @@ class App implements h3d.IDrawable {
 		engine.render(this);
 	}
 
+	/**
+		Update application.
+
+		Called each frame right before rendering.
+		First call is done after the application is set up (so `loadAssets` and `init` are called).
+
+		@param dt Time elapsed since last frame, normalized.
+	**/
+	@:dox(show)
 	function update( dt : Float ) {
 	}