Drag/Drop; Which event do I use that gives me the tile info?

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

Moderators: Lapo, Bax

whornak
Posts: 86
Joined: 22 Sep 2009, 11:05

Drag/Drop; Which event do I use that gives me the tile info?

Postby whornak » 08 Feb 2012, 19:41

I have an inventory item that is placed on the map in several locations. What I need to do is drag/drop an object, not in edit mode, on to any one of them and cause something to happen to that particular one and not the others.

My problem is that the event that I use, the Mouse Up event, doesn't provide enough information about the dropTarget object to know exactly which one it is.

This functionality is in a class these objects are extended from so all of a particular type receive and check for the event and then determine which one will act on it.

What I have been able to do is trap the Mouse Up event and use hitTestObject() function to determine that I am on the correct object.

What I cannot do is retrieve any tile information so I have unique information about each one to help facilitate and store these effects on each object.

For example:

1) I have an inventory item like an empty dog bowl and have added 3 of them to the map during run time editing.
2) I then have a watering jug that I want to fill the bowl with.
3) If each time I go to fill the bowl with water, outside of edit mode, having lets say 1/4 a bowls worth of water, I want to increase the amount of water shown in the bowl.
4) I then drag the jug to partially fill the bowl with water and as a result of the drop operation switch frames to a partially watered bowl.

As stated above, I know which bowl that I am on, but in my scenario there are a couple of things to keep track of for the management of the actions taken as well as re-applying as things are rendered on the map when reloaded.

To answer what will probably be asked, I have to do this outside of edit mode.

Could you provide some direction on how I could handle this?

Thanks.
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 09 Feb 2012, 10:46

I don't think what you need can be achieved, especially using drag&drop. I think you should change the logic, and base it on the triggers you have available on tiles and skins, like the click trigger.
If you check the OpenSpace example, you will see a rocking chair is available. When clicked outside the edit mode, it.. rocks. You might use a similar approach if possible.
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 50 guests