I have used some code I found to try and detect shape collisions. When the ball hits the finish, it should move onto the next scene. I want to to compare the element ID to the correct one in order to move on.
// Fetch physics engine for our hypeDocument
var hypeDocElm = document.getElementById(hypeDocument.documentId());
var engine = hypeDocument.getElementProperty(hypeDocElm, 'physics-engine')
// Event listener
Matter.Events.on(engine, 'collisionStart', function(event) {
// We know there was a collision so fetch involved elements ...
var aElm = document.getElementById(event.pairs[0].bodyA.elementId);
var bElm = document.getElementById(event.pairs[0].bodyB.elementId);
// Now do something with the event and elements
if (aElm.elementId() == "Ball" and bElm.elementId() == "Finish"){
hypeDocument.showNextScene();
}
else if (bElm.elementId() == "Ball" and aElm.elementId() == "Finish"){
hypeDocument.showNextScene();
}
});
Ball Bounce.hype.zip (47.7 KB)
I doesn't seem to work. If anyone could help me that would be great!