Skip to content
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

Merged
merged 2 commits into from
Oct 24, 2024

Conversation

hristo-kanchev
Copy link
Contributor

@hristo-kanchev hristo-kanchev commented Oct 22, 2024

Description:

Updated the documentation for the following h2d sections:

  • H2D-Introduction
  • Objects
  • Object trees
  • Scenes
  • Layers

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

@hristo-kanchev hristo-kanchev changed the title Updated H2D documentation Updated H2D Docs - Objects, ObjectTrees, Scenes, Layers Oct 22, 2024
@hristo-kanchev hristo-kanchev marked this pull request as ready for review October 22, 2024 17:01
@hristo-kanchev hristo-kanchev changed the title Updated H2D Docs - Objects, ObjectTrees, Scenes, Layers Updated H2D sections - Objects, ObjectTrees, Scenes, Layers Oct 22, 2024
@@ -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.
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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();}
Copy link
Contributor Author

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
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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();}
Copy link
Contributor Author

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.

Comment on lines -129 to -141
```

## Scenes and camera

Scenes and camera is explained here.

### Sizing

Scenes sizing is explained here.

### Zoom

Camera zoom is explained here.
Copy link
Contributor Author

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.

@@ -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.
Copy link
Contributor Author

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]].
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed broken link

@yuxiaomao
Copy link
Contributor

Thank you!
As a side note, please avoid force push on reviewed commit, it can be confusing - in your case, simply merge the branch master and push is sufficient. Squash and merge will be used when merging PRs, so the commit history can still remain clean.

@yuxiaomao yuxiaomao merged commit df8f822 into HeapsIO:master Oct 24, 2024
1 check passed
@hristo-kanchev
Copy link
Contributor Author

Thank you! As a side note, please avoid force push on reviewed commit, it can be confusing - in your case, simply merge the branch master and push is sufficient. Squash and merge will be used when merging PRs, so the commit history can still remain clean.

@yuxiaomao Ahh yeah sorry about that. I’ll keep that in mind for next time. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants