-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated H2D sections - Objects, ObjectTrees, Scenes, Layers #102
Conversation
5d3dee4
to
e8d4678
Compare
@@ -6,7 +6,7 @@ When using any `h2d.Scene` (`s2d` when inside `hxd.App`) you have all features o | |||
|
|||
Basically you have two features here: | |||
|
|||
1. The first is you can place `h2d.Object`s at specific layers by `s2d.addChildAt( myobj, MY_LAYER )`. `0` will be the layer the most in the background, while each higher layer is rendered over/above the precedent layer. Usually you predefine your layer indices in some way for instance by `final MY_LAYER_NAME : Int = 23;` (see in the sample below) so you know what each integer (`Int` value) stands for. | |||
1. The first is you can place `h2d.Object`s at specific layers by `s2d.add( myobj, MY_LAYER )`. `0` will be the layer the most in the background, while each higher layer is rendered over/above the precedent layer. Usually you predefine your layer indices in some way for instance by `final MY_LAYER_NAME : Int = 23;` (see in the sample below) so you know what each integer (`Int` value) stands for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a warning if you use addChildAt
which is the following:
"Warning: Previous behavior of Layers.addChildAt
is no longer applicable and Layers.add
should be used instead."
We have now updated the documentation and code sample bellow to reflect the better way of adding child objects to layers.
@@ -18,13 +18,16 @@ Note that the clouds are on top of all other objects. The green soil stains (mea | |||
|
|||
```haxe | |||
|
|||
class LayersDemo extends hxd.App { | |||
class Main extends hxd.App { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to Main
so we don't force the reader to always update their compile.hxml
. It's much easier now to copy and paste code samples and run them.
var clouds : Array<h2d.Object> = []; | ||
var LAYER_FOR_SOIL : Int = 0; | ||
var LAYER_FOR_BUILDINGS : Int = 1; | ||
var LAYER_FOR_SKY : Int = 2; | ||
static function main() {new LayersDemo();} | ||
function new() {super();} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new
is not needed here.
@@ -12,10 +12,14 @@ The child objects will inherit the transformations of the parent object they hav | |||
### Code | |||
|
|||
```haxe | |||
class ObjectTrees extends hxd.App { // ObjectTrees | |||
class Main extends hxd.App { // ObjectTrees |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to Main
so we don't force the reader to always update their compile.hxml
. It's much easier now to copy and paste code samples and run them.
class ABC extends hxd.App { | ||
public static var app : ABC; // just will represent this app as an individual object at runtime (so as an instance of this class) | ||
static function main() { app = new ABC(); } // "save" the reference for access from outside later | ||
class Main extends hxd.App { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to Main
so we don't force the reader to always update their compile.hxml
. It's much easier now to copy and paste code samples and run them.
public var myUpdateFunction : Dynamic; // this will allow us to define the update function from other classes (see Level01) | ||
public function new() {super();} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new
is not needed here.
``` | ||
|
||
## Scenes and camera | ||
|
||
Scenes and camera is explained here. | ||
|
||
### Sizing | ||
|
||
Scenes sizing is explained here. | ||
|
||
### Zoom | ||
|
||
Camera zoom is explained here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing these leftover "todos". We can always add information regarding zoom, sizing, etc. later.
e8d4678
to
74c87d0
Compare
@@ -54,6 +54,6 @@ The underlying `h2d.Object` (from which `h2d.Bitmap` inherits) provides the bitm | |||
|
|||
![h2d_introduction_helloworld2](https://user-images.githubusercontent.com/88530062/174428357-45f857ed-30bf-450d-99b6-72051f5b0b83.png) | |||
|
|||
The [next section](Objects) will discuss `h2d.Object` a bit closer. | |||
The [next section](https://heaps.io/documentation/objects.html) will discuss `h2d.Object` a bit closer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed broken link.
@@ -11,7 +11,7 @@ Like shown previously in the introduction to give our Heaps application visual ( | |||
(See more on [[Drawable]]) | |||
|
|||
## Creating and adding Objects | |||
Objects can be added to a [scene](Scenes) directly (a `h2d.Scene`, for instance `s2d` when inside `hxd.App`) or be added to another `h2d.Object` creating an *object tree*. Object trees are regarded in the next section about [[Object trees]]. | |||
Objects can be added to a [scene](https://heaps.io/documentation/scenes.html) directly (a `h2d.Scene`, for instance `s2d` when inside `hxd.App`) or be added to another `h2d.Object` creating an *object tree*. Object trees are regarded in the next section about [[Object trees]]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed broken link
Thank you! |
@yuxiaomao Ahh yeah sorry about that. I’ll keep that in mind for next time. Thanks! |
Description:
Updated the documentation for the following h2d sections:
The changes contain typo fixes, renaming of class names, fixing broken links and also updating deprecated code.
PS: All code samples have been tested locally to see that they compile and run correctly