You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using this snippet from slingshot.js which has this elastic constraint. I want to make it work like billiard cue ball, that when the user pushes, it should have the elastic behavior but then it should move straight. But due to pointA it doesn't work for me.
here is the snippet:
var anchor = { x: cue.position.x, y: cue.position.y },
elastic = Constraint.create({
pointA: anchor,
bodyB: cue,
stiffness: 0.05,
render: {
lineWidth: 0.5
}
});
Events.on(engine, 'tick', function() {
if (mouseConstraint.mouse.button === -1 && (cue.position.x > 170 || cue.position.y < 330)) {
elastic.bodyB = cue;
//want to update the pointA here but not able to.
}
});
Hi,
I am using this snippet from slingshot.js which has this elastic constraint. I want to make it work like billiard cue ball, that when the user pushes, it should have the elastic behavior but then it should move straight. But due to pointA it doesn't work for me.
here is the snippet:
var anchor = { x: cue.position.x, y: cue.position.y },
elastic = Constraint.create({
pointA: anchor,
bodyB: cue,
stiffness: 0.05,
render: {
lineWidth: 0.5
}
});
Events.on(engine, 'tick', function() {
if (mouseConstraint.mouse.button === -1 && (cue.position.x > 170 || cue.position.y < 330)) {
elastic.bodyB = cue;
//want to update the pointA here but not able to.
}
});
var mouse = Mouse.create(render.canvas),
mouseConstraint = MouseConstraint.create(engine, {
mouse: mouse,
constraint: {
stiffness: 0.2,
render: {
visible: false
}
}
});
I know it's a rookie question to ask, but please any help would be appreciated.
Thanks
The text was updated successfully, but these errors were encountered: