Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ball movement with connected physics #54

Closed
romaniom opened this issue Oct 16, 2023 · 1 comment
Closed

ball movement with connected physics #54

romaniom opened this issue Oct 16, 2023 · 1 comment

Comments

@romaniom
Copy link

hello! I have connected box2d in my project, I need the ball to move at the touch of a button. But nothing works, I've tried a lot of ways, with physics connected, nothing works except impulse and keyboard movement. But I need the ball to move when the button is pressed. Animation doesn't work either.

@danzen
Copy link
Owner

danzen commented Dec 15, 2023

Sorry - missed this until now! You can get us faster at https://zimjs.com/discord or https://zimjs.com/slack. Physics objects are supposed to be controlled by forces. So you want to apply an impulse(x,y) when you press the button.

const button = new Button().center()
button.on("mousedown", ()=>{obj.impulse(100,0);});

will shoot the object to the right for instance.

@danzen danzen closed this as completed Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants