You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Layers.md
+11-8
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ When using any `h2d.Scene` (`s2d` when inside `hxd.App`) you have all features o
6
6
7
7
Basically you have two features here:
8
8
9
-
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.
9
+
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.
10
10
11
11
2. The second feature is that the layer class also allows to control objects individually by `.over()` and `.under()`. Finally you can benefit from the `ysort()` method to order a layer. *In the sample below this will prevent housings to overlap in a weird way. A house farther away from our viewpoint should be rendered behind houses that are closer!*
12
12
@@ -18,13 +18,16 @@ Note that the clouds are on top of all other objects. The green soil stains (mea
18
18
19
19
```haxe
20
20
21
-
class LayersDemo extends hxd.App {
21
+
class Main extends hxd.App {
22
22
var clouds : Array<h2d.Object> = [];
23
23
var LAYER_FOR_SOIL : Int = 0;
24
24
var LAYER_FOR_BUILDINGS : Int = 1;
25
25
var LAYER_FOR_SKY : Int = 2;
26
-
static function main() {new LayersDemo();}
27
-
function new() {super();}
26
+
27
+
static function main() {
28
+
new Main();
29
+
}
30
+
28
31
override function init() {
29
32
engine.backgroundColor = 0xFF33cc33; // game's background color is now green
30
33
for( i in 0...40 )
@@ -56,7 +59,7 @@ class LayersDemo extends hxd.App {
56
59
g.addVertex( -20, 0, 1, 0, 0, 1 );
57
60
g.endFill();
58
61
set_to_random_postion( g );
59
-
s2d.addChildAt( g, LAYER_FOR_BUILDINGS );
62
+
s2d.add( g, LAYER_FOR_BUILDINGS );
60
63
return g; // allows to receive the reference to the created object...
61
64
}
62
65
function add_cloud() {
@@ -75,14 +78,14 @@ class LayersDemo extends hxd.App {
75
78
add_row_of_bubbles( 24, 0 ); // lower level of bubbles
@@ -98,4 +101,4 @@ class LayersDemo extends hxd.App {
98
101
}
99
102
```
100
103
101
-
Note that all we have to use is `s2d.addChildAt( myobj, MY_LAYER )` instead of just `s2d.addChild( myobj )` and finally we use `s2d.ysort( LAYER_FOR_BUILDINGS )` to arrange all houses.
104
+
Note that all we have to use is `s2d.add( myobj, MY_LAYER )` instead of just `s2d.addChild( myobj )` and finally we use `s2d.ysort( LAYER_FOR_BUILDINGS )` to arrange all houses.
Copy file name to clipboardexpand all lines: Objects.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# Object
2
-
Like shown previously in the introduction to give our Heaps application visual (2D) content we need classes that are build upon `h2d.Object`.
2
+
Like shown previously in the introduction to give our Heaps application visual (2D) content we need classes that are built upon `h2d.Object`.
3
3
4
4
- An **Object** (represented by [h2d.Object](https://heaps.io/api/h2d/Object.html)) is the base class of all 2D objects, so any thing that you can *add* to the screen (so to a `h2d.Scene` to be more precise, which mainly is `s2d` when inside `hxd.App`).
5
5
@@ -11,7 +11,7 @@ Like shown previously in the introduction to give our Heaps application visual (
11
11
(See more on [[Drawable]])
12
12
13
13
## Creating and adding Objects
14
-
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]].
14
+
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]].
Copy file name to clipboardexpand all lines: Scenes.md
+18-26
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,13 @@
1
1
# Scenes
2
-
In the precedent sections we already used `s2d` which represents the active current scene rendered by the `hxd.App`.
2
+
In the previous sections we already used `s2d` which represents the active current scene rendered by the `hxd.App`.
3
3
4
4
A **Scene** (represented by [h2d.Scene](https://heaps.io/api/h2d/Scene.html)) represents any scene the user can visit in the Heaps app. Scenes may be *an intro showing the developers logo on start-up*, the *main menu of the game*, maybe a *cutscene* and finally *the level or world* where the actual game takes place and the player walks around.
5
5
6
6
`h2d.Scene` (represented by [h2d.Scene](https://heaps.io/api/h2d/Scene.html)) is a special object (it is actually a `h2d.Object`, too!) which is at the root of the scene tree. In [hxd.App](https://heaps.io/api/hxd/App.html) it is accessible by using the `s2d` variable (as we have seen previously). You will need to add your objects to the scene before they can be displayed. The Scene also handles events such as clicks, touch, and keyboard keys.
7
7
8
8
```haxe
9
-
class Myapp extends hxd.App
10
-
{
11
-
override private function init():Void
12
-
{
9
+
class Main extends hxd.App {
10
+
override private function init():Void {
13
11
super.init();
14
12
s2d; // the current scene
15
13
var myscene = new h2d.Scene(); // create a new scene
@@ -23,7 +21,9 @@ class Myapp extends hxd.App
23
21
24
22
}
25
23
26
-
public static function main(){ new Myapp(); }
24
+
public static function main() {
25
+
new Main();
26
+
}
27
27
}
28
28
```
29
29
@@ -36,14 +36,18 @@ You can deal with scenes mostly any way you like (like with most things in Heaps
0 commit comments