I'd like to create a sequence of letters that can be broken apart. Ideally I'd only load one spritesheet to generate the views of the different letters. I am assigning images to the view of bodies as follows:
// letter is a physicsjs rectangle body
letter.view = new Image();
letter.view.src = 'someImage.jpg';
I'd like to now if there is a way to change the background position of a bitmap assigned to the view of a physicsjs body.
I attempted to use the pixi renderer but kept getting an error:
"undefined is not a function evaluating PIXI.Stage"
So I ended up writing my own solution. In the canvas renderer, in the drawBody() method, I changed:
to:
which allowed me to pass backgroundPosX and/or backgroundPosY as an option when creating a body, and use that offset and a few other different params to position the sprite sheet within a masked area.
The conditional presumes that it must not be a sprite sheet if no backgroundPosX/Y is present. Its there because for some reason this only worked when assigning an image to a body, but not with a body containing only a shape. When a shape only body was created, it kept coming out 2 pixels short of what the assigned width should be, but was perfect when using a body with an image.
This seems like it would be good core functionality, if the discrepancy above was worked out.
Great job on the library too! Looking forward to seeing what else happens with it!