
So I finally got the mouse to access the body to remove it. Next step is to check to see if the value in the body matches the value in the question. Also gotta clean up the arrays once I remove the body to make sure I don’t introduce any “off by one” errors into the code.
Here’s the code for removing a body from the Matter.World.remove(world, body):
// - - - - - - - - - - - - - - - - -
// Sets up mouse constraints
// - - - - - - - - - - - - - - - - -
var mouseConstraint = Matter.MouseConstraint.create(engine, {
element: canvas,
constraint: {
render: {
visible: false
},
stiffness: 0.8
}
});
Matter.World.add(world, mouseConstraint);
// Keep track of the mouse state
var mouseIsDown = false;
Matter.Events.on(mouseConstraint, 'mousedown', function (event) {
var body = mouseConstraint.body;
var ballId = body.id;
var ballValue = balls[ballId - 1];
console.log("mouse down on body with id:" + " " + ballId);
console.log("ball value is:" + " " + ballValue);
var mousePosition = event.mouse.position;
mp = mousePosition;
mouseIsDown = true;
// Removes the body from the world
Matter.World.remove(world, body);
});
Matter.Events.on(mouseConstraint, 'mouseup', function (event) {
// console.log("mouseup called");
var mousePosition = event.mouse.position;
mp = mousePosition;
mouseIsDown = false;
});
Ok so I finally got the mouse events to trigger in the console. I can now report back that I can observe mouse state. The next step is to get the body from the mouseConstraint.
Today I added a label to the game. I put it in a body and wrote an image over it. Next steps will be to remove that image on mouse click. And replace it with a new question.
Ok so I wanted to do something different tonight for development. I’m going to make some predictions – how many things can I get accomplished tonight?
Today I coded up some walls in Matter.js and added them to the Mathogen window. I added some code to create an image from a string of text.
Ok, I’ve decided which framework I’m going to use. I’ve decided to use 
