hello eveyone
I'm making a time trial platformer game in qt5.
I'm trying to detect collosions between the instances of the Background class but it's not working.
[through qDebug(), I found out that it's not even entering the for loop.]
Background class is a subclass of the QGraphicsPixmapItem.
all of the platforms that the player jumps on, are instances of the Background class.
myscene is an instance of the Myscene class which is a subclass of the QGraphicsScene.
m_player is an instance of the Player class which is a subclass of the QGraphicsPixmapItem.
checkcollosion() is called every time scene gets updated.
void Myscene::checkcollosion()
{
QList<QGraphicsItem*> items = collidingItems(m_player);
for (int i=0, number = items.count(); i<number; ++i)
{
if (Background *back = qgraphicsitem_cast<Background*>(items.at(i)))
{
}
}
}
void Myscene::checkcollosion()
{
QList<QGraphicsItem*> items = collidingItems(m_player);
for (int i=0, number = items.count(); i<number; ++i)
{
if (Background *back = qgraphicsitem_cast<Background*>(items.at(i)))
{
}
}
}
To copy to clipboard, switch view to plain text mode
I guess because Background is a subclass of QGraphicsPixmapItem, the collidingItems() doesn't work for it.
and can qgraphicsitem_cast be used for casting QGraphicPixmapItem or is it only for QGraphicsItem ?
so how can I fix this?
Bookmarks