Comments (5)
Sounds like a bug to me.
from boxbox.
Have some more information... if you try want the polygon at location 1,1 and then use the coordinates (assuming a rectangle for example): [{1,1}, {2,1}, {2,2}, {1,2}] then set position to x:1, y:1 then the rectangle will be positioned at 2,2.
If you always assume the polygon is created at origin 0,0 and then set the position then there is no problem. I had assumed you had to calculate the points for the polygon based on your desired starting location, but you have to create the polygon from 0,0.
from boxbox.
Oh that makes sense... I think I've fallen into that trap too come to think of it
from boxbox.
Actually... I've come to another realisation. I had assumed that [0,0] is the object origin (based on my first attempts at creating a poly shape) however I suspect now that the origin point for the poly is acutally the center... so for a rectangle of width 1 and height 1, centered at [0,0] the points would need to be [-0.5, -0.5], [0.5,-0.5], [0.5, 0.5], [-0.5, 0.5].
I assume you are well across this but it took me ages to figure out (also explained why my images were aligning badly and not behaving properly when the object started rotating).
Thanks for listening
from boxbox.
from boxbox.
Related Issues (20)
- docs: "position" link in canvasPosition is broken HOT 1
- document that positions are the "center" of the entity
- ability to change entity options that are changeable
- use offRender instead of unbindOnRender HOT 2
- onRender for entities HOT 1
- Use consistant format for gravity
- If .name is read-only, consider renaming to .getName HOT 1
- image offset cannot be set in pixels
- Support groups, categories, masks
- Entity draw function should pass canvasPosition
- Updating position in collision callback
- The latest submit generate artifacts HOT 3
- imageStretchToFit doesn't work, Entity has wrong boundaries HOT 1
- want to load json object generated by physics-body-editor HOT 4
- Update README with information about grunt HOT 1
- Uncaught TypeError: Cannot read property 'getContext' of null HOT 1
- Is boxbox dead? HOT 4
- gravity function not setting gravity, possible fix provided
- Cannot get sprite sheet to render any sprites
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boxbox.