-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Enhancements #7
Comments
Sprites are not currently supported with the built in renderer, but it's on my todo list. But if you wanted to try it yourself with a custom renderer its possible to copy Render.js, customise it and pass it into the engine through the options. Event callbacks are not yet supported either, again they're on my todo list! For now though, a custom renderer also has access to the entire world state including collisions, so you could try that until I sort it out. |
Thank you. We changed the renderer to draw images. After test, we send the change to you. |
Until I implement a real event system, you should able to do this currently by swapping out e.g. say your new engine is in the variable
Also note that you may need to apply a large force vector to see any result, and it may need to be over a few frames (for the object to pick up speed). Hopefully that will work! When I get around to sorting out events, I'll do an example of this type of thing. |
Thank you. That does the trick only partly. In addition you must subclass Body.js. When the engine runs an update it invokes Body.resetForcesAll. This removes all forces, even the previously applied one. Bofroe you apply the gravity I added: That worked. |
Ah, you're right, the forces will always be reset as it is currently, so that's an issue I'll fix. Also I've noted the issue with sleeping bodies. I'll make it so I should hopefully be working on this again soon. |
Another question: Where do you detect that a collision happened? Also, is there a timestamp to detect if this is an old collision, like an object laying at the bottom ? |
I'm going to add events for collisions in the new system I'm working on, I'll do an example of this |
@abataille I've now implemented the events system, please see the issue for it. Hopefully this allows you to implement what you need regards to applying forces on tick, and handling collision events. If you find issues with the event system please log them in that thread! I also fixed the issue with sleeping bodies, they now wake up when a force is applied :) |
@abataille I've just pushed the new sprites / textures rendering code See the sprites demo. Then see the sprites demo code. |
Marvelous. One question, two suggestions:
Also, I changed the Render.create to: Render.create = function(element,options) {
}; |
Oops forgot to build last time, that's why it's not in matter.js! Thanks for the suggestions, I've implemented them all and will push them soon (including a build). The last part about using a custom canvas. I could not reproduce your issue.
Maybe try like that that? |
This works with your renderer. If I use a copy of your render as my own renderer, Then it seems that I have to use my code. In engine.create you create your renderer. If I don't use it, have have to create my own one first. |
All of the discussed issues above should be solved in the latest release: If any new issues remain, please open a new thread, cheers. |
The text was updated successfully, but these errors were encountered: