object shape in isometric mode
krumza

Hi! I try to make a isometric game with WADE and I see the difficulty to make active only the part of the sprite that I need.
The default rectangle but it's not quite what i want.
For example I have a building with a size of 2 by 2 square, but the building itself is only part of the object.
How to make to be able to outline the contour of the object, and clicking on this would be action

br

All 2 Comments
Gio

Hi

To do that you want to use 2 sprites, not just one. To be clear, it can be one single SceneObject and one tile... but it should be a SceneObject that contains 2 sprites.

Let's say that Sprite 0 is your sprite as it is now. You want to create a new one (Sprite 1), that contains only the clickable area. Basically just cut it out, so the rest of it (that you don't want to be clickable) is transparent.

Set the sort point on sprite one to a larger value on Y - something like {x: 0, y: 1} would work - you can now edit that by dragging the blue dot in the sprite preview window. Move it down until Sprite 1 appears on top of Sprite 0.

Change the offset of Sprite 1 so it overlaps Sprite 0 perfectly, and the player doesn't even notice that it's 2 sprites - it looks like 1 single sprite. Also make sure that, for Sprite 1, you use Pixel Perfect mouse events (make sure that the Pixel Perfect option is selected, as in this picture)

Now in your onClick function, do something like this:

if (data.spriteIndex == 1)
{
    // user has clicked on Sprite 1, do something
}

I hope this makes sense - it sounds more complicated than it actually is, it should only take you a few minutes to set it up in the editor. Let me know if you have any problems.

krumza

Thank you!

Post a reply
Add Attachment
Submit Reply
Login to Reply