QGraphicsItem像素完美碰撞检测器

QGraphicsItem Pixel Perfect Collision Detector

本文关键字:碰撞检测 检测器 碰撞 完美 像素 QGraphicsItem      更新时间:2023-10-16

我想在两个或多个QGraphicsItem之间实现一个像素完美的碰撞检测器。QGraphicsItem类提供了一个使用QPainterPath对象的碰撞检测器,所以现在我想将图像从文件加载到只有不透明像素的QPainterPath(使不透明像素的形状准确(,这样我就可以使用QGraphicsItem自己的碰撞检测器来实现像素完美的碰撞检测器。我想知道有没有什么方法可以做这个把戏??

使用alpha通道的图像时,可以使用QGraphicsPixmapItem。使用

QGraphicsPixmapItem::shapeMode(QGraphicsPixmapitem::MaskShape)

这将基于alpha通道提取遮罩以创建形状。