Decorating Walls

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Post Reply
ohanyan
Posts: 8
Joined: 10 Nov 2009, 23:13

Decorating Walls

Post by ohanyan »

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.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

Can you better describe how this works? What are your 'walls'? Tiles? Or are they drawn on the background? What exactly does it mean that the wallpaper must snap into place? A picture of what you get and how it should work instead would be appreciated.
Paolo Bax
The SmartFoxServer Team
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Post by warhell »

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.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

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.
Paolo Bax
The SmartFoxServer Team
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Post by warhell »

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?
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

I'm not aware of possible fakes you can use, sorry.
Paolo Bax
The SmartFoxServer Team
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Post by warhell »

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?
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

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 ?
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.
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?
We will look into this, thank you for reporting.
Paolo Bax
The SmartFoxServer Team
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Post by warhell »

I created a function called validate tile...

Code: Select all


	private function validateTile(tile:Tile):Boolean
		{
			return false
};
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 =/
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

That's a regression bug! :(
Thank you for reporting.
Paolo Bax
The SmartFoxServer Team
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Post by warhell »

Regression bug? This was actually working fine before, if I return false I can't drop it, but now it allows me to drop regardless.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

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
warhell
Posts: 199
Joined: 18 Aug 2007, 16:49
Location: Silicon Valley, CA
Contact:

Post by warhell »

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
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Post by Bax »

Fixed, thank you for reporting.
Paolo Bax
The SmartFoxServer Team
Post Reply