Tower2::Tower2(QGraphicsItem *parent) { setPixmap(QPixmap(":/pics/turrets.png")); QPointF poly_center(1.5,1.5); poly_center*=130; poly_center=mapToScene(poly_center); QPointF tower_center(x()+50,y()+50); QLineF ln(poly_center,tower_center); Tower::attack_area->setPos(x()+ln.dx(),y()+ln.dy()); //connect timer to aquire_target QTimer *timer = new QTimer(); connect(timer,SIGNAL(timeout()),this,SLOT(aquire_target())); timer->start(1000); }
GreenTower::GreenTower(QGraphicsItem *parent){ // connect a timer to aquire_target QTimer * timer = new QTimer(this); connect(timer,SIGNAL(timeout()),this,SLOT(aquire_target())); timer->start(1000); }