|
@@ -18,25 +18,31 @@ Scene* GameScene::createScene(int level) {
|
|
|
auto scene = Scene::createWithPhysics();
|
|
|
Size visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
|
|
|
- //choose whitch part need to draw, Joint, Shape, Contact, None or All
|
|
|
- // scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
|
|
|
+#ifdef DEBUG
|
|
|
+ scene->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
|
|
|
+#endif
|
|
|
|
|
|
GameScene* layer = GameScene::create();
|
|
|
scene->addChild(layer);
|
|
|
|
|
|
- auto material = PHYSICSBODY_MATERIAL_DEFAULT;
|
|
|
- material.density = 1.0f;
|
|
|
- material.restitution = 1.0f;
|
|
|
- material.friction = 0.0f;
|
|
|
-
|
|
|
// the edge of the screen
|
|
|
- auto body = PhysicsBody::createEdgeBox(visibleSize, material);
|
|
|
+ auto body = PhysicsBody::createEdgeBox(visibleSize, PhysicsMaterial(0.0f, 1.0f, 0.0f));
|
|
|
auto edgeNode = Node::create();
|
|
|
edgeNode->setPosition(Point(visibleSize.width/2,visibleSize.height/2));
|
|
|
body->setDynamic(false);
|
|
|
edgeNode->setPhysicsBody(body);
|
|
|
scene->addChild(edgeNode);
|
|
|
|
|
|
+ // bottom edge
|
|
|
+ auto bottom_body = PhysicsBody::createEdgeBox(Size(visibleSize.width, 0));
|
|
|
+ auto bottomNode = Node::create();
|
|
|
+ bottomNode->setPosition(Point(visibleSize.width/2, 0));
|
|
|
+ bottom_body->setDynamic(false);
|
|
|
+ bottomNode->setTag(BOTTOM_TAG);
|
|
|
+ bottom_body->setContactTestBitmask(0xFFFFFFFF);
|
|
|
+ bottomNode->setPhysicsBody(bottom_body);
|
|
|
+ layer->addChild(bottomNode);
|
|
|
+
|
|
|
auto blocks = BlocksLayer::create();
|
|
|
blocks->setLevel(level);
|
|
|
blocks->setPosition(visibleSize.width/2, visibleSize.height);
|
|
@@ -48,19 +54,18 @@ Scene* GameScene::createScene(int level) {
|
|
|
auto delay_save_level = DelayTime::create(10.0);
|
|
|
CallFunc *runCallback_save_level = CallFunc::create(CC_CALLBACK_0(GameScene::saveLevel, layer));
|
|
|
auto seq_save_level = Sequence::create(delay_save_level, runCallback_save_level, nullptr);
|
|
|
-
|
|
|
- auto delay_triple_balls = DelayTime::create(10.0);
|
|
|
+
|
|
|
CallFunc *runCallback_triple_balls = CallFunc::create(CC_CALLBACK_0(GameScene::tripleBallsAppearance, layer));
|
|
|
- auto seq_triple_balls = Sequence::create(delay_triple_balls, runCallback_triple_balls, nullptr);
|
|
|
-
|
|
|
- auto delay_raquete_ball = DelayTime::create(5.0);
|
|
|
+ auto seq_triple_balls = Sequence::create(runCallback_triple_balls, nullptr);
|
|
|
CallFunc *runCallback_raquete_ball = CallFunc::create(CC_CALLBACK_0(GameScene::raqueteBallAppearance, layer));
|
|
|
- auto seq_raquete_ball = Sequence::create(delay_raquete_ball, runCallback_raquete_ball, nullptr);
|
|
|
-
|
|
|
+ auto seq_raquete_ball = Sequence::create(runCallback_raquete_ball, nullptr);
|
|
|
+
|
|
|
layer->runAction(seq_save_level);
|
|
|
layer->runAction(seq_triple_balls);
|
|
|
layer->runAction(seq_raquete_ball);
|
|
|
|
|
|
+ layer->addAndThrowBall();
|
|
|
+
|
|
|
return scene;
|
|
|
}
|
|
|
|
|
@@ -83,33 +88,26 @@ bool GameScene::init() {
|
|
|
audio->preloadEffect("win.wav");
|
|
|
|
|
|
auto visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
+ this->width = visibleSize.width;
|
|
|
+ this->height = visibleSize.height;
|
|
|
Vec2 origin = Director::getInstance()->getVisibleOrigin();
|
|
|
|
|
|
// Adiona o fundo
|
|
|
auto bg = LayerColor::create(COLOR_back);
|
|
|
this->addChild(bg);
|
|
|
|
|
|
-
|
|
|
- auto ball = Ball::create();
|
|
|
- ball->setPosition(visibleSize.width / 2, RAQUETE_ALTURA+BALL_SIZE);
|
|
|
- ball->throwBall();
|
|
|
- this->addChild(ball, 21);
|
|
|
-
|
|
|
- // Inicialmente tem 1 bola
|
|
|
- ball_count = 1;
|
|
|
-
|
|
|
raquete = DrawNode::create();
|
|
|
- raquete_size = RAQUETE_WIDTH;
|
|
|
- float py = RAQUETE_HEIGHT/2.0;
|
|
|
- float pxl = - RAQUETE_WIDTH/2;
|
|
|
- float pxr = RAQUETE_WIDTH/2;
|
|
|
+ raquete_size = PADDLE_WIDTH;
|
|
|
+ float py = PADDLE_HEIGHT/2.0;
|
|
|
+ float pxl = - PADDLE_WIDTH/2;
|
|
|
+ float pxr = PADDLE_WIDTH/2;
|
|
|
raquete->drawSegment(Vec2(pxl, py), Vec2(pxr, py), py, Color4F(COLOR_grey));
|
|
|
raquete->setPositionX(visibleSize.width/2);
|
|
|
- raquete->setPositionY(RAQUETE_ALTURA);
|
|
|
+ raquete->setPositionY(PADDLE_ALTURA);
|
|
|
|
|
|
- auto bsize = Size(RAQUETE_WIDTH+RAQUETE_HEIGHT, RAQUETE_HEIGHT);
|
|
|
+ auto bsize = Size(PADDLE_WIDTH+PADDLE_HEIGHT, PADDLE_HEIGHT);
|
|
|
auto physicsBody = PhysicsBody::createBox(bsize, PhysicsMaterial(0.1f, 1.0f, 0.0f));
|
|
|
- physicsBody->setPositionOffset(Vec2(0, RAQUETE_HEIGHT/2));
|
|
|
+ physicsBody->setPositionOffset(Vec2(0, PADDLE_HEIGHT/2));
|
|
|
physicsBody->setGravityEnable(false);
|
|
|
physicsBody->setDynamic(false);
|
|
|
physicsBody->setContactTestBitmask(0xFFFFFFFF);
|
|
@@ -124,7 +122,7 @@ bool GameScene::init() {
|
|
|
listener1->onTouchBegan = [=](Touch* touch, Event* event){
|
|
|
raquete->setPositionX(touch->getLocation().x);
|
|
|
float px = touch->getLocation().x;
|
|
|
- if (px >= RAQUETE_WIDTH/2 && px < visibleSize.width - RAQUETE_WIDTH/2)
|
|
|
+ if (px >= PADDLE_WIDTH/2 && px < visibleSize.width - PADDLE_WIDTH/2)
|
|
|
raquete->setPositionX(touch->getLocation().x);
|
|
|
return true; // if you are consuming it
|
|
|
};
|
|
@@ -132,33 +130,33 @@ bool GameScene::init() {
|
|
|
// trigger when moving touch
|
|
|
listener1->onTouchMoved = [=](Touch* touch, Event* event){
|
|
|
float px = touch->getLocation().x;
|
|
|
- if (px >= RAQUETE_WIDTH/2 && px <= visibleSize.width - RAQUETE_WIDTH/2)
|
|
|
+ if (px >= PADDLE_WIDTH/2 && px <= visibleSize.width - PADDLE_WIDTH/2)
|
|
|
raquete->setPositionX(touch->getLocation().x);
|
|
|
};
|
|
|
|
|
|
-
|
|
|
+
|
|
|
// Add listener
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener1, this);
|
|
|
-
|
|
|
- // the edge of bottom
|
|
|
- auto body = PhysicsBody::createEdgeBox(Size(visibleSize.width, 0));
|
|
|
- auto edgeNode = Node::create();
|
|
|
- edgeNode->setPosition(Point(visibleSize.width/2, 0));
|
|
|
- body->setDynamic(false);
|
|
|
- edgeNode->setTag(BOTTOM_TAG);
|
|
|
- body->setContactTestBitmask(0xFFFFFFFF);
|
|
|
- edgeNode->setPhysicsBody(body);
|
|
|
- this->addChild(edgeNode);
|
|
|
|
|
|
// Evento no contato das bolas
|
|
|
auto contactListener = EventListenerPhysicsContact::create();
|
|
|
contactListener->onContactBegin = CC_CALLBACK_1(GameScene::onContactBegin, this);
|
|
|
_eventDispatcher->addEventListenerWithSceneGraphPriority(contactListener, this);
|
|
|
|
|
|
+ balls = Node::create();
|
|
|
+ this->addChild(balls, 21);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+void GameScene::addAndThrowBall() {
|
|
|
+ auto visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
+ Ball* ball = Ball::create();
|
|
|
+ ball->setPosition(visibleSize.width / 2, PADDLE_ALTURA+BALL_SIZE);
|
|
|
+ ball->throwBall();
|
|
|
+ balls->addChild(ball, 21);
|
|
|
+}
|
|
|
+
|
|
|
bool GameScene::onContactBegin(PhysicsContact& contact) {
|
|
|
auto nodeA = contact.getShapeA()->getBody()->getNode();
|
|
|
auto nodeB = contact.getShapeB()->getBody()->getNode();
|
|
@@ -187,7 +185,7 @@ bool GameScene::onContactBegin(PhysicsContact& contact) {
|
|
|
} else if (nodeB->getTag() == BALL_TAG && nodeA->getTag() == CORE_TAG) {
|
|
|
caseBallCore(nodeA, nodeB);
|
|
|
} else if (nodeB->getTag() == SAVE_TAG && nodeA->getTag() == RACKET_TAG) {
|
|
|
- caseSaveLevel(nodeB);
|
|
|
+ caseSaveLevel(nodeB);
|
|
|
} else if (nodeB->getTag() == THREE_BALLS_TAG && nodeA->getTag() == RACKET_TAG) {
|
|
|
caseTripleBalls(nodeB);
|
|
|
} else if (nodeB->getTag() == RACKET_BALL_TAG && nodeA->getTag() == RACKET_TAG) {
|
|
@@ -199,26 +197,25 @@ bool GameScene::onContactBegin(PhysicsContact& contact) {
|
|
|
} else if (nodeB->getTag() == RACKET_BALL_TAG && nodeA->getTag() == BOTTOM_TAG) {
|
|
|
nodeB->removeFromParentAndCleanup(true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
void GameScene::caseBallCollision (Node *ball) {
|
|
|
- // Destrói a bola que tocou o fundo
|
|
|
- ball_count--;
|
|
|
+
|
|
|
auto audio = CocosDenshion::SimpleAudioEngine::getInstance();
|
|
|
audio->playEffect("bomb.wav");
|
|
|
ParticleSun* m_emitter = ParticleSun::create();
|
|
|
m_emitter->setPosition(ball->getPosition());
|
|
|
m_emitter->setDuration(1);
|
|
|
- this->getScene()->addChild(m_emitter);
|
|
|
+ this->addChild(m_emitter);
|
|
|
ball->removeFromParentAndCleanup(true);
|
|
|
|
|
|
- if (ball_count == 0) {
|
|
|
+ if (balls->getChildrenCount() == 0) {
|
|
|
this->over = true;
|
|
|
auto visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
- auto text = Label::createWithTTF("Game Over...", "fonts/Marker Felt.ttf", 40);
|
|
|
+ auto text = Label::createWithTTF("Game Over...", FONT, 40);
|
|
|
text->setPosition(visibleSize.width/2, visibleSize.height/2);
|
|
|
this->addChild(text);
|
|
|
|
|
@@ -230,6 +227,7 @@ void GameScene::caseBallCollision (Node *ball) {
|
|
|
auto *menu = Menu::create(menu_item_start, NULL);
|
|
|
menu->setPosition(Point(0, 0));
|
|
|
this->addChild(menu, 30);
|
|
|
+ balls->removeFromParentAndCleanup(true);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -256,33 +254,23 @@ void GameScene::caseBallCore (Node *core, Node *ball) {
|
|
|
}
|
|
|
|
|
|
void GameScene::caseSaveLevel(Node *powerup_ball) {
|
|
|
- if (!this->over) {
|
|
|
- Size visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
-
|
|
|
- // Salva o nivel!
|
|
|
- UserDefault *userdata = UserDefault::getInstance();
|
|
|
- userdata->setIntegerForKey("level", this->level);
|
|
|
- userdata->setDoubleForKey("time", (double) time(NULL));
|
|
|
- userdata->flush();
|
|
|
- auto text = Label::createWithTTF("Level Saved!", "fonts/Marker Felt.ttf", 40);
|
|
|
- text->setPosition(visibleSize.width/2, visibleSize.height/2);
|
|
|
- this->addChild(text);
|
|
|
- text->runAction(FadeOut::create(3));
|
|
|
- }
|
|
|
+ UserDefault *userdata = UserDefault::getInstance();
|
|
|
+ userdata->setIntegerForKey("level", this->level);
|
|
|
+ userdata->setDoubleForKey("time", (double) time(NULL));
|
|
|
+ userdata->flush();
|
|
|
powerup_ball->removeFromParentAndCleanup(true);
|
|
|
}
|
|
|
|
|
|
void GameScene::NextLevel(Ref *pSender) {
|
|
|
auto scene = GameScene::createScene(this->level + 1);
|
|
|
Director::getInstance()->replaceScene(scene);
|
|
|
- //Director::getInstance()->end();
|
|
|
}
|
|
|
|
|
|
void GameScene::setLevel(int level) {
|
|
|
this->level = level;
|
|
|
char level_text[256];
|
|
|
sprintf(level_text,"Level %d", this->level);
|
|
|
- auto text = Label::createWithTTF(level_text, "fonts/Marker Felt.ttf", 30);
|
|
|
+ auto text = Label::createWithTTF(level_text, FONT, 30);
|
|
|
text->setAnchorPoint(Vec2());
|
|
|
text->setPosition(10, 10);
|
|
|
this->addChild(text);
|
|
@@ -294,13 +282,8 @@ void GameScene::saveLevel() {
|
|
|
Size visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
auto ball_draw = DrawNode::create();
|
|
|
ball_draw->drawDot(Vec2(0, 0), BALL_SIZE/3.0, Color4F(COLOR_green));
|
|
|
-
|
|
|
- auto material = PHYSICSBODY_MATERIAL_DEFAULT;
|
|
|
- material.density = 0.0f;
|
|
|
- material.restitution = 1.0f;
|
|
|
- material.friction = 0.0f; //set friction here
|
|
|
-
|
|
|
- auto physicsBody = PhysicsBody::createCircle(BALL_SIZE/3.0, material);
|
|
|
+
|
|
|
+ auto physicsBody = PhysicsBody::createCircle(BALL_SIZE/3.0, PhysicsMaterial(0.0f, 1.0f, 0.0f));
|
|
|
physicsBody->setGravityEnable(true);
|
|
|
physicsBody->setVelocity(Vec2(0,0));
|
|
|
physicsBody->setLinearDamping(0.0);
|
|
@@ -324,27 +307,23 @@ void GameScene::saveLevel() {
|
|
|
// Power-up: deixa 3 bolas na tela ao invés de 1
|
|
|
void GameScene::tripleBallsAppearance() {
|
|
|
if (rand_0_1() < DROP_TRIPLE_BALL && this->over == false){
|
|
|
- Size visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
- auto ball_draw = DrawNode::create();
|
|
|
- ball_draw->drawDot(Vec2(0, 0), BALL_SIZE/3.0, Color4F(COLOR_pink));
|
|
|
+ Size visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
+ auto ball_draw = DrawNode::create();
|
|
|
+ ball_draw->drawDot(Vec2(0, 0), BALL_SIZE/3.0, Color4F(COLOR_pink));
|
|
|
|
|
|
- auto material = PHYSICSBODY_MATERIAL_DEFAULT;
|
|
|
- material.density = 0.0f;
|
|
|
- material.restitution = 1.0f;
|
|
|
- material.friction = 0.0f;
|
|
|
|
|
|
- auto physicsBody = PhysicsBody::createCircle(BALL_SIZE/3.0, material);
|
|
|
- physicsBody->setGravityEnable(true);
|
|
|
- physicsBody->setVelocity(Vec2(0,0));
|
|
|
- physicsBody->setLinearDamping(0.0);
|
|
|
- physicsBody->setMass(1.0f);
|
|
|
- physicsBody->setContactTestBitmask(0xFFFFFFFF);
|
|
|
- physicsBody->setGroup(-1);
|
|
|
- ball_draw->addComponent(physicsBody);
|
|
|
- ball_draw->setTag(THREE_BALLS_TAG);
|
|
|
-
|
|
|
- ball_draw->setPosition(visibleSize.width * rand_0_1(), visibleSize.height);
|
|
|
- this->addChild(ball_draw);
|
|
|
+ auto physicsBody = PhysicsBody::createCircle(BALL_SIZE/3.0, PhysicsMaterial(0.0f, 1.0f, 0.0f));
|
|
|
+ physicsBody->setGravityEnable(true);
|
|
|
+ physicsBody->setVelocity(Vec2(0,0));
|
|
|
+ physicsBody->setLinearDamping(0.0);
|
|
|
+ physicsBody->setMass(1.0f);
|
|
|
+ physicsBody->setContactTestBitmask(0xFFFFFFFF);
|
|
|
+ physicsBody->setGroup(-1);
|
|
|
+ ball_draw->addComponent(physicsBody);
|
|
|
+ ball_draw->setTag(THREE_BALLS_TAG);
|
|
|
+
|
|
|
+ ball_draw->setPosition(visibleSize.width * rand_0_1(), visibleSize.height);
|
|
|
+ this->addChild(ball_draw);
|
|
|
}
|
|
|
|
|
|
auto delay = DelayTime::create(rand_0_1()*10.0);
|
|
@@ -354,21 +333,7 @@ void GameScene::tripleBallsAppearance() {
|
|
|
}
|
|
|
|
|
|
void GameScene::caseTripleBalls(Node *powerup_ball) {
|
|
|
- if (!over) {
|
|
|
- Size visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
- auto text = Label::createWithTTF("Triple Balls!", "fonts/Marker Felt.ttf", 40);
|
|
|
- text->setPosition(visibleSize.width/2, visibleSize.height/2 + 2);
|
|
|
- this->addChild(text);
|
|
|
- text->runAction(FadeOut::create(3));
|
|
|
-
|
|
|
- // cria as bolas e as adiciona no cenário
|
|
|
- for (int i = ball_count; i < 3; i++, ball_count++) {
|
|
|
- auto ball = Ball::create();
|
|
|
- ball->setPosition(raquete->getPositionX(), RAQUETE_ALTURA+BALL_SIZE+i);
|
|
|
- ball->throwBall();
|
|
|
- this->addChild(ball, 21);
|
|
|
- }
|
|
|
- }
|
|
|
+ alert(MSG_TRIPE_BALLS);
|
|
|
powerup_ball->removeFromParentAndCleanup(true);
|
|
|
}
|
|
|
|
|
@@ -376,14 +341,9 @@ void GameScene::raqueteBallAppearance() {
|
|
|
if (rand_0_1() < DROP_RACKET_BALL && this->over == false){
|
|
|
Size visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
auto ball_draw = DrawNode::create();
|
|
|
- ball_draw->drawDot(Vec2(0, 0), BALL_SIZE/3.0, Color4F(COLOR_blue));
|
|
|
+ ball_draw->drawDot(Vec2(0, 0), BALL_SIZE/3.0, Color4F(COLOR_blue));
|
|
|
|
|
|
- auto material = PHYSICSBODY_MATERIAL_DEFAULT;
|
|
|
- material.density = 0.0f;
|
|
|
- material.restitution = 1.0f;
|
|
|
- material.friction = 0.0f;
|
|
|
-
|
|
|
- auto physicsBody = PhysicsBody::createCircle(BALL_SIZE/3.0, material);
|
|
|
+ auto physicsBody = PhysicsBody::createCircle(BALL_SIZE/3.0, PhysicsMaterial(0.0f, 1.0f, 0.0f));
|
|
|
physicsBody->setGravityEnable(true);
|
|
|
physicsBody->setVelocity(Vec2(0,0));
|
|
|
physicsBody->setLinearDamping(0.0);
|
|
@@ -392,7 +352,7 @@ void GameScene::raqueteBallAppearance() {
|
|
|
physicsBody->setGroup(-1);
|
|
|
ball_draw->addComponent(physicsBody);
|
|
|
ball_draw->setTag(RACKET_BALL_TAG);
|
|
|
-
|
|
|
+
|
|
|
ball_draw->setPosition(visibleSize.width * rand_0_1(), visibleSize.height);
|
|
|
this->addChild(ball_draw);
|
|
|
}
|
|
@@ -403,46 +363,46 @@ void GameScene::raqueteBallAppearance() {
|
|
|
this->runAction(seq);
|
|
|
}
|
|
|
|
|
|
-/* Power-up/down: 50% de chance de dobrar o tamanho da raquete,
|
|
|
- e 50% de chance de diminuir seu tamanho pela metade.
|
|
|
- Para não ficar muito fácil/difícil, impusemos tamanho mínimo/máximo da raquete.
|
|
|
-*/
|
|
|
+/* Power-up/down: 50% de chance de dobrar o tamanho da raquete,
|
|
|
+ e 50% de chance de diminuir seu tamanho pela metade.
|
|
|
+ Para não ficar muito fácil/difícil, impusemos tamanho mínimo/máximo da raquete.
|
|
|
+ */
|
|
|
void GameScene::caseRaqueteBall(Node *powerup_ball) {
|
|
|
if (!over) {
|
|
|
char power_text[256];
|
|
|
-
|
|
|
+
|
|
|
if (rand_0_1() < 0.5) {
|
|
|
- if (raquete_size <= RAQUETE_WIDTH * 4) {
|
|
|
+ if (raquete_size <= PADDLE_WIDTH * 4) {
|
|
|
sprintf(power_text, "Doubled racket size!");
|
|
|
raquete_size *= 2;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
else {
|
|
|
- if (raquete_size >= RAQUETE_WIDTH / 4) {
|
|
|
+ if (raquete_size >= PADDLE_WIDTH / 4) {
|
|
|
sprintf(power_text, "Doubled racket size!");
|
|
|
raquete_size /= 2;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
Size visibleSize = Director::getInstance()->getVisibleSize();
|
|
|
- auto text = Label::createWithTTF(power_text, "fonts/Marker Felt.ttf", 40);
|
|
|
+ auto text = Label::createWithTTF(power_text, FONT, 40);
|
|
|
text->setPosition(visibleSize.width/2, visibleSize.height/2 + 2);
|
|
|
this->addChild(text);
|
|
|
text->runAction(FadeOut::create(3));
|
|
|
-
|
|
|
+
|
|
|
//cria uma nova raquete e substitui a antiga raquete
|
|
|
auto new_raquete = DrawNode::create();
|
|
|
- float py = RAQUETE_HEIGHT/2.0;
|
|
|
+ float py = PADDLE_HEIGHT/2.0;
|
|
|
float pxl = - raquete_size/2;
|
|
|
float pxr = raquete_size/2;
|
|
|
new_raquete->drawSegment(Vec2(pxl, py), Vec2(pxr, py), py, Color4F(COLOR_grey));
|
|
|
new_raquete->setPositionX(raquete->getPositionX());
|
|
|
- new_raquete->setPositionY(RAQUETE_ALTURA);
|
|
|
+ new_raquete->setPositionY(PADDLE_ALTURA);
|
|
|
|
|
|
- auto bsize = Size(raquete_size+RAQUETE_HEIGHT, RAQUETE_HEIGHT);
|
|
|
+ auto bsize = Size(raquete_size+PADDLE_HEIGHT, PADDLE_HEIGHT);
|
|
|
auto physicsBody = PhysicsBody::createBox(bsize, PhysicsMaterial(0.1f, 1.0f, 0.0f));
|
|
|
- physicsBody->setPositionOffset(Vec2(0, RAQUETE_HEIGHT/2));
|
|
|
+ physicsBody->setPositionOffset(Vec2(0, PADDLE_HEIGHT/2));
|
|
|
physicsBody->setGravityEnable(false);
|
|
|
physicsBody->setDynamic(false);
|
|
|
physicsBody->setContactTestBitmask(0xFFFFFFFF);
|
|
@@ -456,3 +416,12 @@ void GameScene::caseRaqueteBall(Node *powerup_ball) {
|
|
|
powerup_ball->removeFromParentAndCleanup(true);
|
|
|
}
|
|
|
|
|
|
+void GameScene::alert(std::string text) {
|
|
|
+ if (!this->over) {
|
|
|
+ auto display_label = Label::createWithTTF(text, FONT, 40);
|
|
|
+ display_label->setPosition(this->width/2, this->height/2);
|
|
|
+ this->addChild(display_label);
|
|
|
+ display_label->runAction(FadeOut::create(3));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|