Event listeners in plugin?

For developers using the Construct 2 Javascript SDK

Post » Wed Sep 11, 2013 10:04 pm

Can event listeners like onmousedown be used in plugins?Kahless2013-09-11 22:07:16
B
5
Posts: 14
Reputation: 253

Post » Thu Sep 12, 2013 8:46 am

Of course. That's how all the input plugins work. You just have to be careful that if you capture an event and stop its propagation, other plugins won't see it.Ashley2013-09-12 08:46:29
Scirra Founder
B
399
S
236
G
89
Posts: 24,543
Reputation: 195,430

Post » Thu Sep 12, 2013 5:37 pm

Awesome. Thanks for the response. Iv'e been looking at some of the plugins and the templates trying to figure out how everything fits together. I'm trying to have a plugin that distorts an image based on mouse input.I see plugins that draw images are of the world type and plugins that capture user input are of the type object. Is it possible to have one plugin that does both. Or do I need to have my plugin communicate with the mouse plugin? If so then whats the best way to set up the event sheet. I was thinking some thing like mouse-left button is down, then have that call a function.

function mouseDown(e){
     mouseIsDown=true;
     mouseDownPosLastX=e.clientX;
     mouseDownPosLastY=e.clientY;     
}

So my plugin can see the x and y position. Is this type of interaction possible? Sorry for hitting you with so many questions at once.   Kahless2013-09-12 17:49:39
B
5
Posts: 14
Reputation: 253

Post » Fri Sep 13, 2013 5:27 am

After much trial and error I have determined it is possible for one plugin to both draw images and interprets user input. Now the only question is are there any draw backs to setting up a plugin this way?
B
5
Posts: 14
Reputation: 253

Post » Fri Sep 13, 2013 12:17 pm

You can set up plugins however you like. It's just javascript code.
Scirra Founder
B
399
S
236
G
89
Posts: 24,543
Reputation: 195,430

Post » Thu Oct 03, 2013 10:41 am

@ Kahless

Do you have any sucess with that plugin of yours?
B
29
S
11
G
2
Posts: 692
Reputation: 5,159


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests