melonJS icon indicating copy to clipboard operation
melonJS copied to clipboard

Issues in Tutorial

Open austynmahoney opened this issue 15 years ago • 5 comments

There are some issues I encountered in the tutorial that caused quite a few headaches.

The first one I came upon was a syntax error in the enemy Entity code. There is a >= with a space between the > and =. The typo is in the update function in the else...if.

 // manage the enemy movement
    update: function() {
        // ... code before

        if (this.alive) {
            if (this.walkLeft && this.pos.x < = this.startX) {
                this.walkLeft = false;
            } else if (!this.walkLeft && this.pos.x > = this.endX) { //******  > = should be >= ******
                this.walkLeft = true;
            }

            //... code after
    }

The next issue I came across was the lack of explanation of Objects and Entities. I think just a couple lines explaining how to add and edit an entity to the object layer would make it much easier to follow for a newcomer to the engine. I got lost here for a while and had to backtrack to figure out where I went wrong.

Thanks!

austynmahoney avatar Oct 17 '11 14:10 austynmahoney

I would agree. I went through every single option i could find on Tiled before figuring out exactly how to add an entity. The ">=" caused an additional 20 minutes of headache before figuring it out.

Lewk avatar Oct 17 '11 14:10 Lewk

How to add an entity was my biggest problem with the tutorial. I think another potential problem was getting the home screen working. I knew that I would have to add it to the resources, but only because everything else had to be added to the resources.

prestonberrett avatar Oct 17 '11 15:10 prestonberrett

@austynmahoney good catch ! I'll correct this tonight :)

@rberret I already corrected this missing part a couple of days ago, if you check the online tutorial again, it's now mentioned that the background asset should be added to the resource list.

ghost avatar Oct 18 '11 02:10 ghost

Corrected, I'm closing the issue. For information, this was due to auto-reformatting of the code in the HTML, provided code example in the zip file was correct.

concerning the entity creation, I though the following chapter from the Tutorial was quite straightforward :

And now we can add our entity into the level! Go back to Tiled, add an new Object Layer, and finally a new Entity. Name it (case does not matter) mainPlayer (or using the same name you used when adding our Object into the entityPool), and add two properties to the Object :

  • image with the gripe_run_right value (name of our resource
  • spritewidth with the value 64 which is the size of a single sprite in the spritesheet These two parameters will be passed as parameters (settings object here above used by the constructor) when the object will be created. Now you can either specify these fields here in Tiled, or directly in your code (when dealing with multiple objects, it can be easier to just specify the name in Tiled, and manage the rest in the constructor directly).

ghost avatar Oct 18 '11 15:10 ghost

Just in case anyone else comes upon this.

I had the same problem as others with adding an entity and found the solution here:

https://groups.google.com/forum/#!searchin/melonjs/tutorial$20entity/melonjs/WOIJdY46R-E/W_qLzQETMaUJ

Xifip avatar Jan 18 '13 17:01 Xifip