Page 1 of 1
mapInteractionEvent SKIN_CLICK help
Posted: 25 Oct 2010, 09:06
by HHJsyndrome
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");
}
Posted: 25 Oct 2010, 10:26
by TiagoR
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)
Posted: 26 Oct 2010, 09:05
by HHJsyndrome
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...
Posted: 26 Oct 2010, 14:44
by Bax
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.
Posted: 27 Oct 2010, 03:39
by HHJsyndrome
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
Posted: 27 Oct 2010, 21:44
by Bax
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.
Posted: 28 Oct 2010, 03:01
by HHJsyndrome
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.
Thanks.
Posted: 06 Aug 2011, 12:33
by li_ramen07
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?
Posted: 11 Aug 2011, 12:23
by Bax
Try this:
Code: Select all
var myTile:Tile = mySkin.parent.parent as Tile;