本文整理汇总了C++中Dot::initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ Dot::initialize方法的具体用法?C++ Dot::initialize怎么用?C++ Dot::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dot
的用法示例。
在下文中一共展示了Dot::initialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resetGame
void myGame::resetGame()
{
ghosts.clear();
dots.clear();
//create patterns
Pattern* ghostPattern1 = new Pattern(1);
ghostPattern1->addStep(0, "CAMP", 40, [&] (Entity* e) {
Ghost* myself = static_cast<Ghost*>(e) ;
int waypoint = myself->targetWaypoint ;
VECTOR2 center = *myself->getCenter() ;
float left_edge = myself->getX();
float right_edge = myself->getX() + myself->getWidth()*myself->getScale();
float top_edge = myself->getY();
float bottom_edge = myself->getY() + myself->getHeight()*myself->getScale();
VECTOR2 currentWaypoint = waypointSet1[waypoint] ;
if( currentWaypoint.x > left_edge &&
currentWaypoint.x < right_edge &&
currentWaypoint.y > top_edge &&
currentWaypoint.y < bottom_edge)
myself->targetWaypoint++ ;
if( myself->targetWaypoint > 3) myself->targetWaypoint = 0 ;
myself->waypointTrack(waypointSet1[waypoint]);
myself->vectorTrack(&player, 180);
}) ;
Pattern* ghostPattern2 = new Pattern(1);
ghostPattern2->addStep(0, "CAMP", 40, [&] (Entity* e) {
Ghost* myself = static_cast<Ghost*>(e) ;
int waypoint = myself->targetWaypoint ;
VECTOR2 center = *myself->getCenter() ;
float left_edge = myself->getX();
float right_edge = myself->getX() + myself->getWidth()*myself->getScale();
float top_edge = myself->getY();
float bottom_edge = myself->getY() + myself->getHeight()*myself->getScale();
VECTOR2 currentWaypoint = waypointSet2[waypoint] ;
if( currentWaypoint.x > left_edge &&
currentWaypoint.x < right_edge &&
currentWaypoint.y > top_edge &&
currentWaypoint.y < bottom_edge)
myself->targetWaypoint++ ;
if( myself->targetWaypoint > 3) myself->targetWaypoint = 0 ;
myself->waypointTrack(waypointSet2[waypoint]);
myself->vectorTrack(&player, 180);
}) ;
//create entities
// ghost 1
Ghost* ghost1 = new Ghost() ;
if (!ghost1->initialize(this, ghostNS::WIDTH, ghostNS::HEIGHT, 4, &allTM))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ghost entity"));
ghost1->setX(0);
ghost1->setY(0);
ghosts.add(ghost1, new Pattern(ghostPattern1));
// ghost 2
Ghost* ghost2 = new Ghost() ;
if (!ghost2->initialize(this, ghostNS::WIDTH, ghostNS::HEIGHT, 4, &allTM))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ghost entity"));
ghost2->setX(GAME_WIDTH - ghostNS::WIDTH*ghostNS::SCALE);
ghost2->setY(GAME_HEIGHT - ghostNS::HEIGHT*ghostNS::SCALE);
ghost2->setCurrentFrame(1);
ghosts.add(ghost2, new Pattern(ghostPattern2));
// dots
rows = 4 ;
cols = 5 ;
for(int i = 0; i < rows; ++i)
{
for(int j = 0; j < cols; ++j)
{
Dot* newDot = new Dot() ;
if (!newDot->initialize(this, dotNS::WIDTH, dotNS::HEIGHT, 4, &allTM))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing dot entity"));
newDot->setX( ((GAME_WIDTH/cols)*j) + 50);
newDot->setY( ((GAME_HEIGHT/rows)*i) + 50);
newDot->setScale(dotNS::SCALE);
dots.add(newDot);
}
}
dotsRemaining = rows * cols ;
}