-
Notifications
You must be signed in to change notification settings - Fork 95
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
Problem with nested bodies #97
Comments
This has nothing to do with The tricky part is of course to find a way to do it properly in QML. In an imperative language, it would be easy since you would just have a class that you pass a reference to the world, and it would instantiate all its parts inside that world, along with joints to hold things together. I think in QML you'd need to do something similar, for example by setting the |
Yes, @bjorn you are right. It just maybe I put it wrong when said "nested". Sure I talk about Item {
id: car
Wheels {}
Engine {}
Wagon {}
...
} when each component located in different file. |
@folibis Actually your example for grouping car elements should work fine as long as your top-level car item sits at 0,0 and is not transformed. Basically, you need to avoid introducing any new coordinate systems because these do not exist in Box2D. The following approach may work to position car elements without relying on a coordinate system that does not match up with the world: Item {
id: car
property real carX: 0
property real carY: 0
Wheel { x: carX; y: carY + 50 }
Wheel { ... }
Engine { ... }
Wagon { ... }
...
} |
…ox2d#108 Added qmltypes to make system for Qml tooling. qml-box2d#109 Added qrc file for common icons and removed doubles. qml-box2d#110 Added a example applicaiton that makes it so one can test out all the exmaples without qmlscence. qml-box2d#111 made all examples install to qt's example dir in prep for docs and better stucture, qml-box2d#112 , qml-box2d#13 Set up stucture and role back point for qt-ish style of libs and plugins,
…d#109 qrc & icons. qml-box2d#110 qmlscence optinal. qml-box2d#111 , qml-box2d#112 qt's example dir in prep for docs
Since Body object isn't derived now from
QQuickItem
sometimes I meet difficulties with nested items. For example suppose we have custom component in Wheel.qml:Now I want to use this component in the main scene:
The scene now looks not as expected. The reason is that
wheel
positioned is local coordinates (x=0,y=0) relative to its parent butwheelBody
is positioned in world coordinates (x=300,y=200) so body and its traget are not syncronized.I think it's serious problem since nested bodies is not allowed. In more or less compicated games bodies are compound.
The text was updated successfully, but these errors were encountered: