Decorating Walls
Decorating Walls
We've come across an interesting problem. We have walls in the game, and are implementing a "wallpapering" feature. This is common on many 2.5D games these days. Unfortunately there is no way for us to "Snap" the wallpaper into place.
How do we go about implementing this kind of feature. Where the wallpaper can only be added to a wall - and it would be great if the wallpaper automatically snapped as well.
How do we go about implementing this kind of feature. Where the wallpaper can only be added to a wall - and it would be great if the wallpaper automatically snapped as well.
Hi Bax, I'm working with ohanyan on the same project.
Here is the question in more detail: We would like to have a set of inventory items that can only be placed in the outer perimeter of the map. These items will be wallpaper, which would snap on to pre-existing "wall: items that cannot be removed by the user.
By snapping we mean that the items can ONLY be place on these out perimeter items, so if the user hovers over a square in the middle of the map, the item would be snapping to one of the outer perimeter tiles.
For example, in the Openspace2 example one of the inventory items is a chimney, but the user is able to place a chimney item where ever they wish. So the user can actually put a chimney in the middle of the room, which looks a bid odd since part of the items background is the matching wallpaper. We would like to limit the item placement of the chimney such that it can only be placed on the walls of the room, plus we would like for the chimney to snap to a wall regardless of where it's being dragged when they user attempts to drag it into the room.
Here is the question in more detail: We would like to have a set of inventory items that can only be placed in the outer perimeter of the map. These items will be wallpaper, which would snap on to pre-existing "wall: items that cannot be removed by the user.
By snapping we mean that the items can ONLY be place on these out perimeter items, so if the user hovers over a square in the middle of the map, the item would be snapping to one of the outer perimeter tiles.
For example, in the Openspace2 example one of the inventory items is a chimney, but the user is able to place a chimney item where ever they wish. So the user can actually put a chimney in the middle of the room, which looks a bid odd since part of the items background is the matching wallpaper. We would like to limit the item placement of the chimney such that it can only be placed on the walls of the room, plus we would like for the chimney to snap to a wall regardless of where it's being dragged when they user attempts to drag it into the room.
Ok, much more clear.
In order to force users to place those items on the perimeter you can use the OpenSpace.tileDropValidator property: it's a function you pass to OpenSpace which is called each time an item is dragged on the map. The destination Tile object is passed to the function, so you can read its coordinates: if the dragged item is of type "wall only" and the destination px=0 or py=0, return true (drop allowed), otherwise return false.
Unfortunately the snap feature can't be implemented.
In order to force users to place those items on the perimeter you can use the OpenSpace.tileDropValidator property: it's a function you pass to OpenSpace which is called each time an item is dragged on the map. The destination Tile object is passed to the function, so you can read its coordinates: if the dragged item is of type "wall only" and the destination px=0 or py=0, return true (drop allowed), otherwise return false.
Unfortunately the snap feature can't be implemented.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
bax wrote:Ok, much more clear.
In order to force users to place those items on the perimeter you can use the OpenSpace.tileDropValidator property: it's a function you pass to OpenSpace which is called each time an item is dragged on the map. The destination Tile object is passed to the function, so you can read its coordinates: if the dragged item is of type "wall only" and the destination px=0 or py=0, return true (drop allowed), otherwise return false.
Unfortunately the snap feature can't be implemented.
Thanks a lot! Would there be any way to fake the user such that even though, for example, the user is hovering an item in the middle of the map, the user is actually hovering the item on one of the outer wall items (fake mouse x,y coords)? Which would simulate the "snapping" effect?
Say in the case where I would only like the user to be able to drag on chair per tile, but still be able to drag a floor pattern and then a chair on the floor pattern. What would be the easiest implementation for this? Is there a way to know what item the user is currently dragging so I can check that against the tile that goes through in OpenSpace.tileDropValidator ?
Also, just a note, I'm not sure if the tileDropValidator was implemented with this intention, but it seems to be called whenever the user is hovering over the map in edit mode, regardless if the user is dragging an item onto the map. Is this a bug? Is there a point to calling this function when the user is not dragging something?
Also, just a note, I'm not sure if the tileDropValidator was implemented with this intention, but it seems to be called whenever the user is hovering over the map in edit mode, regardless if the user is dragging an item onto the map. Is this a bug? Is there a point to calling this function when the user is not dragging something?
Not sure I understand this properly. Are you saying you want the user to be able to drag a chair on a floor pattern tile, but not a chair on a chair? If yes, this is very simple: set the allowDrop property of the chair tile to false. This will prevent any other tile from being drop on it during runtime editing.Say in the case where I would only like the user to be able to drag on chair per tile, but still be able to drag a floor pattern and then a chair on the floor pattern. What would be the easiest implementation for this? Is there a way to know what item the user is currently dragging so I can check that against the tile that goes through in OpenSpace.tileDropValidator ?
We will look into this, thank you for reporting.Also, just a note, I'm not sure if the tileDropValidator was implemented with this intention, but it seems to be called whenever the user is hovering over the map in edit mode, regardless if the user is dragging an item onto the map. Is this a bug? Is there a point to calling this function when the user is not dragging something?
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
I created a function called validate tile...
This should allow no tiles to be added, and when I hover over the map with a dragged inventory item it highlights each tile in a red color, but when I let go of the mouse the item is still added =/
Code: Select all
private function validateTile(tile:Tile):Boolean
{
return false
};
That is what regression means... something that was working before, stops working after a change (and the change was made when you reported that the drop validator function was called even if the user wasn't dragging an item). We have fixed this and will make it available in the official release.
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Ahh I see, thanks! I notice that openspace 2 was officially released today, but I'm unable to download it after I fill the form located here...
http://www.openspace-engine.com/download
http://www.openspace-engine.com/download