Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by congwang0517

impactjs has entity click event?
must I write a plugin?

1 decade ago by dominic

Create a Cursor entity and use Impact&039;s #check() function to check if the cursor is touching another entity. See this thread for an example.

1 decade ago by Graphikos

I'm not a fan of the "cursor entity"... here is another way to check for it: http://pointofimpactjs.com/snippets/view/16/entity-click

1 decade ago by ShawnSwander

I really like the simplicity of this method Graphikos. I have my background clicks do a pathing function though is there a way to prevent that update from occurring when an entity is clicked?

1 decade ago by Graphikos

Preventing "click-though" is a bit of a challenge. In theory a way is to set a boolean when an entity is clicked. Have your background check to make sure that boolean is false before running it's event. Thus only the entity will fire.

The other way I've dealt with this is create an array of all the elements that are inFocus(). Then trigger the event for the first element only. If you don't have multiple entities stacked on top of each other this method might be a bit of an over-kill.

Hope that helps. I don't have much for example code to show at the moment.

1 decade ago by ShawnSwander

@Graphikos
I tried that. The issue was both entities catch the click event and both are processed at the time time even when I assigned timers to force the background to go second it didn't work the way I hoped. I suppose I could try to call functions on click. If something works Ill post it.
Page 1 of 1
« first « previous next › last »