javascript - How do I create an HTML message for a mouseConstraint on this cradle? -


this i'm trying work on right now, matter.js library. want use 2 events trigger 2 html messages grabbing ball on left side of cradle "hey grabbed cradle" , when let go, "wow, @ that!".

// matter.js - http://brm.io/matter-js/  // matter module aliases var engine = matter.engine,     world = matter.world,     body = matter.body,     composites = matter.composites,     mouseconstraint = matter.mouseconstraint;  // create matter.js engine var engine = engine.create(document.body, {   render: {     options: {       showangleindicator: true,       showvelocity: true,       wireframes: false     }   } });  // add mouse controlled constraint var mouseconstraint = mouseconstraint.create(engine); world.add(engine.world, mouseconstraint);  // add newton's cradle (using composites factory method!) var cradle = composites.newtonscradle(280, 150, 5, 30, 200); world.add(engine.world, cradle);  // offset first body in cradle swing body.translate(cradle.bodies[0], { x: 0, y: 0 });  // run engine engine.run(engine); 

where @ trying make happen at:

cradle.mouseconstraint=function(){alert("hi")}; 

for more information, here codepen: http://codepen.io/liabru/pen/abfml


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -