开发者

How to handle multiple collision type in c++?

开发者_运维问答

I'm building a game in c++ using Qt. I got the collision detection right using GraphicsItem methods the thing is that I don't know how to deal with every different collision type as there is different objects with different behaviour.


I guess that you are using one of the collidingItems or collidesWithItem methods. From these you get a list of QGraphicsItems. Then it is just a matter of casting to determine what hit what and reacting.


It's actually possible to know which kind of object participate in the collision, through custom type, see the documentation for more info http://doc.qt.io/qt-5/qgraphicsitem.html#type

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜