Hi,
Has anybody tried this modification? I'm not sure if I did something, but this is what I have tried before and my cannon's color never changed each time I pressed the shoot button.
Here's the simple code modification that didnt work for me:
void CannonField::paintCannon( QPainter& painter )
{
painter.setPen( Qt::NoPen );
if( autoShootTimer->isActive() )//bullet is in the air
{
painter.setBrush( Qt::red );
}
else //bullet is not in the air
{
painter.setBrush(Qt::blue);
}
painter.save();
painter.translate(0, height());
painter.
drawPie(QRect(-35,
-35,
70,
70),
0,
90 * 16 );
painter.rotate(-currentAngle);
painter.drawRect(barrelRect);
painter.restore();
}
void CannonField::paintCannon( QPainter& painter )
{
painter.setPen( Qt::NoPen );
if( autoShootTimer->isActive() )//bullet is in the air
{
painter.setBrush( Qt::red );
}
else //bullet is not in the air
{
painter.setBrush(Qt::blue);
}
painter.save();
painter.translate(0, height());
painter.drawPie(QRect(-35, -35, 70, 70), 0, 90 * 16 );
painter.rotate(-currentAngle);
painter.drawRect(barrelRect);
painter.restore();
}
To copy to clipboard, switch view to plain text mode
Bookmarks