Parasyte

Members
  • Content count

    108
  • Joined

  • Last visited

About Parasyte

  • Rank
    Advanced Member

Contact Methods

  • Twitter
    kodewerx

Recent Profile Visitors

418 profile views
  1. You have to pass true as the second arg to removeChild. See documentation: http://melonjs.github.io/melonJS/docs/me.Container.html#removeChild
  2. You can pull the existing container out with me.game.world.removeChild(container, true) The second arg instructs the container to keep its children alive. As long as you have a reference held on `container` e.g. in the global namespace called "game", the container won't be GC'd. You can add it later with me.game.world.addChild(container) Use these methods together to swap containers.
  3. The z-index is the Z-coordinate in the 3D vector used for element positioning; this.pos.z
  4. I think you're "opening it" as if it was an application. Double-clicking on the .js file should really just open your favorite code editor with the file's contents. It sounds like you're double-clicking on it and Windows Script Host is trying to execute it, which is not at all what you want. Have you tried going through the tutorials? They describe step-by-step how to use the engine.
  5. Weird, the rawgit CDN doesn't support release links! I never noticed that. The master.zip is an archive containing the source code release. The build releases are one of these two: https://github.com/melonjs/melonJS/releases/download/4.1.1/melonJS-min.js https://github.com/melonjs/melonJS/releases/download/4.1.1/melonJS.js The first link is the compressed build, and the second one is the "debug" build. You can also use the boilerplate project, which contains everything you need to get started: https://github.com/melonjs/boilerplate/archive/master.zip And follow one of the tutorials to learn how to use it: http://melonjs.github.io/tutorial-platformer/ http://melonjs.github.io/tutorial-space-invaders/ Happy game dev'ing!
  6. I recommend adjusting the collision shape(s) on the entity body. If you only have one shape, it's very easy. // When `this` references a me.Entity var shape = this.body.getShape(0); shape.resize(shape.width, 200); this.body.updateBounds(); If you're not using the me.Entity class, then you can adjust the bounding rectangle directly. But as obiot pointed out, the bounding rect is just a cache, and melonJS will wipe it out on you. (So use me.Entity) // When `this` references a me.Sprite var shape = this.getBounds(); shape.resize(shape.width, 200);
  7. Argh, really? We're just using github to host the downloads. Maybe you will have better luck fetching it through the CDN? https://cdn.rawgit.com/melonjs/melonJS/releases/download/4.1.1/melonJS-min.js
  8. That's a very detailed diagram you drew! The coordinates work like this: The origin is placed in the upper left corner at <0, 0> The uppermost top of the map is placed at <mapWidth, 0> The game world container will be sized to: w=mapWidth*2, h=mapHeight mapOffset is defined as a vector: `var mapOffset = new me.Vector2d(mapWidth, 0);` Transformation from TMX coordinates to melonJS coordinates is: `new me.Vector2d(mapX, mapY).toIso().add(mapOffset)` Transformation from melonJS coordinates to TMX coordinates is: `new me.Vector2d(melonjsX, melonjsY).sub(mapOffset).to2d()` The mapOffset is there to shift the coordinate space so the origin is at the upper left corner of the container (not at the upper center, as shown in your diagram). This keeps the implementation clean so we don't have to do anything with negative coordinates. It's a bit of a drawback, but I digress. Given these functions, you should have a fairly simple way to translate between the coordinate spaces. Note that "melonJS coordinates" that I reference above are the world space coordinates. If you need screen space coordinates, you must first use the localToWorld and worldToLocal methods that obiot mentioned. These functions will convert between world space and screen space. Then the above functions will convert between world space and TMX map space coordinates. It's a lot to digest! But hopefully that helps you. Just try to keep in mind that you are working with three different coordinate spaces. If you cleanly separate them, you shouldn't have a whole lot of trouble with it.
  9. You can actually use a me.Container for the renderable instead of me.Sprite, then add the me.Sprite and the font object as children of the container. All children are positioned relative to the parent, so dragging the parent will do what you want without any extra work.
  10. Yeah, you can just change the `z` property on the entity at runtime. You might have to sort the container after changing the depth, but that's really easy. Just call the container's sort method.
  11. The forum was recently migrated to a new host. (details) I did a quick search for our previous discussion, and I didn't find any of those posts, either. I'll email Rich about it.
  12. Can I ask why you're changing the animation speed after the animation is created? We would recommend you just create additional animations if you need a slower or faster version using the same frames but a different speed.
  13. Ok, I see where the maths are going wrong. The TMX data uses positions in orthographic space. (!) So my understanding was completely opposite of reality. melonJS transforms the TMX positions into isometric screen space with the toIso() method, and offsets the position by the map width (to prevent using negative coordinates) When you want to transform the melonJS internal position back to orthographic space for TMX, you must first subtract the map width from the X coordinate, then call the to2d() method.
  14. https://github.com/melonjs/melonJS/blob/a3ce0fb994da2bd41d357e1dd2c240fe45a2c34c/tests/spec/vect2d-spec.js#L160-L168 These expectations are definitely not right. On second look, they are definitely right. It follows the logic described here: http://clintbellanger.net/articles/isometric_math/
  15. FWIW, you should be able to write the code like this: console.log('pos:', this.pos.x, this.pos.y); var iso = this.pos.clone().toIso(); console.log('iso:', iso.x, iso.y); But anyway, it sounds like the toIso() method is returning incorrect coordinates. But you didn't say whether the first log shows <3500,3500> or something else. The way I understand it, your data structure will have <3500,3500> which is in isometric space, and melonJS will have something else (orthographic space), and the toIso() method will correct it back to <3500,3500> in isometric space.