-
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
Single sprite covering a composite body? #153
Comments
Currently the function copies all of the options to all of the body parts, looks like I need to add an exception so that sprites don't get copied. In the meantime, after you create your body, can you try loop through |
Been working on this here, too. Looping through body.parts isn't enough, On Wed, Sep 16, 2015 at 6:58 AM, Liam notifications@github.com wrote:
|
Please do share an example that demonstrates the issues. Compound bodies are a relatively new feature and support for rendering is pretty limited right now.
This is correct, I assumed earlier that you only wanted one sprite for the whole body. If you actually do want different sprites for each part, then things will be trickier to set up initially. |
No, no, I want to do one sprite per the entire object. I guess my Using the SVG demo as a base, I'm able to pull in non-convex polygon shapes I'm looking to do just one sprite for the entire body and I'm having some Different sprites per body part would be cool, but I'm not looking for that On Wed, Sep 16, 2015 at 9:59 AM, Liam notifications@github.com wrote:
|
Actually, looks like this is due to an oversight in Render.js line 431. The offset is assumed to be half the sprite dimension, but this only works when the centre of mass is the same as the centre of the sprite. Doh. Looks like a fix is needed here! |
I've sort of got one, but at the moment it requires me to pass in the My codes in no shape to just push it to the project. If you want to email It's pretty fast, but I've noticed an odd behavior in the process. If I On Thu, Sep 17, 2015 at 2:11 PM, Liam notifications@github.com wrote:
|
I would love to see an example of this code. Currently attempting to do the same thing—applying a texture to a concave composite body. |
Hi Brian, I have it, but it's ugly. I'm quite hesitant to put it in the Ed On Sun, Jan 24, 2016 at 2:12 PM, Brian Moore notifications@github.com
|
I took a stab at a pretty simple solution to this, where I modified the renderer to render the main body and not the parts when it has a sprite. See my pull request. |
You might be able to use fillstyle = canvas pattern to achieve something similar: |
@majman Awesome! Love it. |
Anyone coming across this. I had some success with creating a rectangle that has a collision filter of 0 (to not collide with anything) that would serve to hold the sprite. Then I attached it to the body using 2 constraints. It can sometimes be slightly jittery, but for my purposes it achieved what I needed:
|
@willmcl Awesome solution! Works even better, if constraints have slightly increased stiffness. I tried 1.1 |
I'm experimenting with importing shapes from SVG, and that's working pretty well, but I'd like to apply a single sprite over top of the composite body that's created. (See the svg demo stuff; Bodies.fromVerticies).
Is there an easy way to do this? Currently, it applies the same sprite to all composite shapes.
Thanks!
The text was updated successfully, but these errors were encountered: