Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Collision detect of items doesn't work or suported in Quick 2.0!

$
0
0
Hi all! First, I know there are a lot of threads posted about that topic. I have read all, also googled and spent a lot of time – without any success :-( I use Qt 5.2 with Quick 2.0 to implement a very simple game. There are some items placed in the main view (collectables). Then there is a dragable item (catcher) which you can dragging around the main view. Always when the catcher collids with a collectable I want to recognize that. THAT’S ALL what I want! *Please guys: * Don’t tell me yet there are a lot of 3rd party libs available like Box2D or you can do that all with JS! No comments, only facts/examples please! I have read too much threads without any results – only trash talk, no solutions. Earlier in an older application I used the Graphics Framework which is behind the Quick 1. There is a QGraphicsItem class with collidingItems() method. Great! But since Quick 2 the complete render system changed to OpenGL and what ever. The new corresponding class QQuickItem doesn’t have any such colliding methods. I think it’s very poor if such a greatful, complex framework like Quick 2 doesn’t support that elementary functions like collison detects. That throws Quick back to the dark age. Ok, I can change back to Quick 1 but the docs says: Newer applications should use Quick 2. Or is going back to Quick 1 actually the best way? How is the port of Quick 1 to Android? Have anybody a simple, clear suggestion how I can implement a collision detect in Quick 2? I tried something like that in JS where x, y comes from the dragable item (iterating about all childs): function collisionDetect(x, y) {   for (var i; i < mainView.children.length; i++) {  var item = mainView.children[i]  if (item.contains(x, y) && item.objectName == "collectable")   console.log("yeahh!") } But the contains() returns always true! What a f…! I have tested it with a global MouseArea, catched in onClicked the position and passed it also to contains(). The same: Always true! But the point is definitly outside the item! Thanks for any answers.

Viewing all articles
Browse latest Browse all 4972

Trending Articles