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");
}
mapInteractionEvent SKIN_CLICK help
-
- Posts: 23
- Joined: 05 Oct 2010, 09:28
Hi,
Since you didnt gave your full code see if it looks like this
Dont forget to set the tile triggers in openspace ( type:click, Target:ShopkeeperDU and the Params if you need any)
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
-
- Posts: 23
- Joined: 05 Oct 2010, 09:28
yea, I did exactly the same I think so, but nothing happens when I clicked the skin of the tile.
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...
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...
-
- Posts: 23
- Joined: 05 Oct 2010, 09:28
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
That tile was set to non walkable already, but the event just won't fire
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.
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
The SmartFoxServer Team
-
- Posts: 23
- Joined: 05 Oct 2010, 09:28
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.
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.
-
- Posts: 34
- Joined: 16 Feb 2011, 06:01
- Location: Philippines
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
on sleepless roads the sleepless go
Try this:
Code: Select all
var myTile:Tile = mySkin.parent.parent as Tile;
Paolo Bax
The SmartFoxServer Team
The SmartFoxServer Team
Return to “OpenSpace v2 discussions and help”
Who is online
Users browsing this forum: No registered users and 32 guests