mapInteractionEvent SKIN_CLICK help

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

Moderators: Lapo, Bax

HHJsyndrome
Posts: 23
Joined: 05 Oct 2010, 09:28

mapInteractionEvent SKIN_CLICK help

Postby HHJsyndrome » 25 Oct 2010, 09:06

can someone give some tips on how to use the SKIN click event?

Currently what I'm trying to do is to create a shopkeeper inside a room, when the person clicks on the shop keeper he will open up the buy/sell inventory and player can buy things from the list and so on.

Right now I'm just testing the trigger but it doesn't seem to work.

I have set in open space the image of the shopkeeper onto a tile
I set the tile to be a non walkable one and set its name.

so I kinda edited the mapInteraction manager in the example and wrote this below because I thought the trigger target should be referring to the name of the tile or something but when I click nothing happens.

Can someone enlighten me on this?

else if (trigger.target == "ShopkeeperDU") //open selling items
{
main.logTrace("Hi Im shopkeeper");
}
TiagoR
Posts: 83
Joined: 15 Mar 2010, 11:42
Location: Portugal
Contact:

Postby TiagoR » 25 Oct 2010, 10:26

Hi,
Since you didnt gave your full code see if it looks like this

Code: Select all

openSpace.addEventListener(MapInteractionEvent.SKIN_CLICK, onSkinInteraction);

function onSkinInteraction(evt:MapInteractionEvent):void
{
   var trigger:Trigger = evt.params.trigger;
   
   if (evt.type == MapInteractionEvent.SKIN_CLICK)
   {
      if (trigger.target == "ShopkeeperDU")
      {
         trace("Hi im the shopkeeper!");
      }
   }
   
   trace("Trigger target: " + trigger.target)
   trace("Trigger params: " + trigger.params)
}



Dont forget to set the tile triggers in openspace ( type:click, Target:ShopkeeperDU and the Params if you need any)
TR
HHJsyndrome
Posts: 23
Joined: 05 Oct 2010, 09:28

Postby HHJsyndrome » 26 Oct 2010, 09:05

yea, I did exactly the same I think so, but nothing happens when I clicked the skin of the tile.

Code: Select all

private function onSkinInteraction(evt:MapInteractionEvent):void
      {
         var skin:DisplayObject = evt.params.skin
         var trigger:Trigger = evt.params.trigger
            
         if (evt.type == MapInteractionEvent.SKIN_CLICK)
         {
            
            //my shopkeeper
            if (trigger.target == "ShopkeeperDU") //open selling items
            {
               main.logTrace("Hi Im shopkeeper");
               outLineMe(skin);
               //trigger.target = null;
            }
         
         
         main.logTrace("\tTrigger target: " + trigger.target)
         main.logTrace("\tTrigger params: " + trigger.params)
      }
}


my settings for the tile in the world editor was tile walkable,
type : click Trigger: ShopkeeperDU

strangely ... the only time the trace("Hi Im shopkeeper") only came out when the map was loaded...
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 26 Oct 2010, 14:44

If the tile is walkable, the mouse sensor inside the tile "catches" the mouse before the underlying skin. You should make the tile non-walkable (if possible), or use a Tile Trigger instead of a Skin Trigger.
Paolo Bax
The SmartFoxServer Team
HHJsyndrome
Posts: 23
Joined: 05 Oct 2010, 09:28

Postby HHJsyndrome » 27 Oct 2010, 03:39

yes, I intended to make the shopkeeper's tile non walkable, but when the non walkable property is set, I won't be able to set the tile instance triggers in openspace editor.. so how do I asssign the skin click trigger to the skin in the openspace editor?

That tile was set to non walkable already, but the event just won't fire
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 27 Oct 2010, 21:44

Do not confuse skin triggers and tile triggers. Skin triggers are defined in the TILE EDITOR, clicking on the skin in the preview area and opening the skin instance panel. Tile triggers are defined in the MAP EDITOR, in a similar way.
If a tile is non-walkable, tile triggers are not fired, but skin triggers should.
Also make sure your skin's mouseChildren property is not set to true somewhere in your code.
Paolo Bax
The SmartFoxServer Team
HHJsyndrome
Posts: 23
Joined: 05 Oct 2010, 09:28

Postby HHJsyndrome » 28 Oct 2010, 03:01

Ahh okay.. it works now.. I was looking for the skin instance trigger for quite some time already. I thought it was located at the skin editor guess not..

So, does openspace provide anything that helps with the creation of NPC chat dialogs? If not, what would be a good way to implement them? For example, when you click on the NPC a dialog would pop out asking if the user would like to by or sell and so on. :lol:

Thanks.
li_ramen07
Posts: 34
Joined: 16 Feb 2011, 06:01
Location: Philippines

Postby li_ramen07 » 06 Aug 2011, 12:33

bax wrote:If a tile is non-walkable, tile triggers are not fired, but skin triggers should.
Also make sure your skin's mouseChildren property is not set to true somewhere in your code.


Is there a way to get a reference to the "parent" tile of the skin that was clicked? I have this tile with two skins, one of which has a skin click trigger. When this skin is clicked, i want to do something with the second skin. How would i be able to do get this?
Li Ramen


on sleepless roads the sleepless go
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 11 Aug 2011, 12:23

Try this:

Code: Select all

var myTile:Tile = mySkin.parent.parent as Tile;
Paolo Bax
The SmartFoxServer Team

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 57 guests