Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
Ryeeeeee committed Mar 14, 2014
2 parents 58e96c1 + 793dc8a commit 8aa7859
Showing 12 changed files with 157 additions and 147 deletions.
1 change: 1 addition & 0 deletions Classes/Enemies.cpp
Original file line number Diff line number Diff line change
@@ -213,6 +213,7 @@ void BigDude::die(){
log("now X: %f Y:%f \n",nowPoint.x,nowPoint.y);
Point targetPos = Point(nowPoint.x,nowPoint.y-200);
log("now X: %f Y:%f \n",targetPos.x,targetPos.y);
unscheduleAllSelectors();
this->runAction(
Sequence::create(
Spawn::create(
3 changes: 3 additions & 0 deletions Classes/GameControllers.cpp
Original file line number Diff line number Diff line change
@@ -233,6 +233,9 @@ void EnemyController::erase(int i)
case kEnemyBigDude:
_bigDudePool.pushBack(static_cast<BigDude*>(e));
break;
case kEnemyBoss:
_bossPool.pushBack(static_cast<Boss*>(e));
break;
}
enemies.erase(i);
e->removeFromParentAndCleanup(false);
21 changes: 11 additions & 10 deletions Classes/GameLayer.cpp
Original file line number Diff line number Diff line change
@@ -27,16 +27,16 @@ bool GameLayer::isDie=false;
bool GameLayer::init()
{
//************** animation cache ******************
auto animation = Animation::create();
animation->setDelayPerUnit(0.1);
auto texture = Director::getInstance()->getTextureCache()->addImage("player_bullet_explosion.png");
animation->addSpriteFrameWithTexture(texture, Rect(0,0,26,17));
animation->addSpriteFrameWithTexture(texture, Rect(0,18,26,22));
animation->addSpriteFrameWithTexture(texture, Rect(0,40,26,20));
animation->addSpriteFrameWithTexture(texture, Rect(0,61,26,23));

//animation->retain();
AnimationCache::getInstance()->addAnimation(animation,"bullet_expl");
// auto animation = Animation::create();
// animation->setDelayPerUnit(0.1);
// auto texture = Director::getInstance()->getTextureCache()->addImage("player_bullet_explosion.png");
// animation->addSpriteFrameWithTexture(texture, Rect(0,0,26,17));
// animation->addSpriteFrameWithTexture(texture, Rect(0,18,26,22));
// animation->addSpriteFrameWithTexture(texture, Rect(0,40,26,20));
// animation->addSpriteFrameWithTexture(texture, Rect(0,61,26,23));
//
// animation->retain();
// AnimationCache::getInstance()->addAnimation(animation,"bullet_expl");

_spr = Sprite::create("groundLevel.jpg");
addChild(_spr, -5);
@@ -231,6 +231,7 @@ void GameLayer::removeBulletAndEnmeys(float dt)
{
//EnemyController::erase(i);
EnemyController::showCaseEnemies.at(i)->removeFromParentAndCleanup(false);
EnemyController::showCaseEnemies.erase(i);
}
for(int i=BulletController::bullets.size()-1;i>=0;i--)
{
12 changes: 8 additions & 4 deletions Classes/GameOverLayer.cpp
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
#include "GameLayer.h"
#include "GameControllers.h"
#include "AirCraft.h"
#include "Bullets.h"

GameOverLayer* GameOverLayer::create(int score)
{
@@ -114,17 +115,20 @@ void GameOverLayer::menu_backtomenu()
Director::getInstance()->replaceScene(MainMenuScene::createScene());
for(int i=EnemyController::enemies.size()-1;i>=0;i--)
{
EnemyController::erase(i);
EnemyController::enemies.at(i)->removeFromParentAndCleanup(true);
}
EnemyController::enemies.clear();
for(int i=EnemyController::showCaseEnemies.size()-1;i>=0;i--)
{
EnemyController::showCaseEnemies.at(i)->removeFromParentAndCleanup(false);
EnemyController::showCaseEnemies.erase(i);
EnemyController::showCaseEnemies.at(i)->removeFromParentAndCleanup(true);
//EnemyController::showCaseEnemies.erase(i);
}
EnemyController::showCaseEnemies.clear();
for(int i=BulletController::bullets.size()-1;i>=0;i--)
{
BulletController::erase(i);
BulletController::bullets.erase(i);
}
BulletController::bullets.clear();
}

void GameOverLayer::menu_playagain_Callback(Ref* sender)
10 changes: 0 additions & 10 deletions Classes/HelloWorldScene.cpp
Original file line number Diff line number Diff line change
@@ -91,16 +91,6 @@ bool HelloWorld::init()

NotificationCenter::getInstance()->destroyInstance();
NotificationCenter::getInstance()->addObserver(this,callfuncO_selector(HelloWorld::ShowGameOver),"ShowGameOver",NULL);

// Easter Egg
// auto cocos = Sprite3D::create("coconut.obj", "coco.png");
// auto coco = cocos;
// addChild(coco);
// coco->setScale(1);
// coco->setOutline(10, Color3B(0,0,0));
// coco->setPosition(320,480);
// coco->runAction(RepeatForever::create(RotateBy::create(0.3, Vertex3F(10,12,13))));
//glEnable(GL_DEPTH_TEST);

return true;
}
7 changes: 7 additions & 0 deletions Classes/LoadingScene.cpp
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@ int LoadingScene::m_curPreload_BigDude_count=0;
int LoadingScene::m_curPreload_Missile_count=0;
int LoadingScene::m_curPreload_Boss_count=0;

int LoadingScene::audioloaded = false;
int LoadingScene::particleloaded = false;

LoadingScene::~LoadingScene()
{
}
@@ -103,8 +106,10 @@ void LoadingScene::InitCoco()

void LoadingScene::LoadingResource()
{
if(!particleloaded)
LoadingParticle();
//Loading Music
if(!audioloaded)
LoadingMusic();

//Loading Picture
@@ -113,6 +118,7 @@ void LoadingScene::LoadingResource()

void LoadingScene::LoadingMusic()
{
audioloaded = true;
auto Audio = CocosDenshion::SimpleAudioEngine::getInstance();
Audio->preloadEffect("explodeEffect.mp3");
Audio->preloadEffect("hit.mp3");
@@ -269,6 +275,7 @@ void LoadingScene::LoadingBullet(int type)

void LoadingScene::LoadingParticle()
{
particleloaded = true;
auto particle=ParticleManager::getInstance();
particle->AddPlistData("missileFlare.plist","missileFlare");
particle->AddPlistData("emission.plist", "emission");
6 changes: 4 additions & 2 deletions Classes/LoadingScene.h
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ class LoadingScene : public Layer
virtual bool init();

void update(float dt);

static int audioloaded;
CREATE_FUNC(LoadingScene);

private:
@@ -54,6 +54,7 @@ class LoadingScene : public Layer
void GotoNextScene();
void RunNextScene(float dt);


private:
static bool isReg;
int currentNum;
@@ -69,7 +70,8 @@ class LoadingScene : public Layer
static int m_curPreload_Boss_count;

static int updatecount;


static int particleloaded;
};


7 changes: 5 additions & 2 deletions Classes/MainMenuScene.cpp
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
#include "PublicApi.h"
#include "Plane.h"
#include "GameLayer.h"
#include "HelloWorldScene.h"
USING_NS_CC;

Scene* MainMenuScene::createScene()
@@ -120,7 +121,8 @@ void MainMenuScene::update(float dt){
plane->setPosition3D(Vertex3F(visible_size_macro.width/2+50,480-20*sin(1.05*pRate),0));
}

void MainMenuScene::startgame(Ref* sender){
void MainMenuScene::startgame(Ref* sender)
{
startgame_item->runAction(Sequence::create(ScaleTo::create(0.1f, 1.4f),
ScaleTo::create(0.1f, 1.2f),
ScaleTo::create(0.1f, 1.3f),
@@ -131,7 +133,8 @@ void MainMenuScene::startgame_callback()
{
CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic();
GameLayer::isDie=false;
Director::getInstance()->replaceScene(LoadingScene::createScene());
auto scene = (LoadingScene::audioloaded) ? HelloWorld::createScene() :LoadingScene::createScene();
Director::getInstance()->replaceScene(scene);
}

void MainMenuScene::credits(Ref* sender){
12 changes: 7 additions & 5 deletions Classes/Player.cpp
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@
bool Player::init()
{
_Model = Sprite3D::create("playerv002.obj", "playerv002_256.png");
//_Model = Sprite3D::create("Scania4.obj", "car00.png");
if(_Model)
{
_Model->setScale(8);
@@ -117,18 +116,22 @@ void Player::stop()
unschedule(schedule_selector(Player::shoot));
unschedule(schedule_selector(Player::shootMissile));
}

void Player::hideWarningLayer()
{
setVisible(false);
}
bool Player::hurt(float damage){
float fromHP = _HP;
float toHP = _HP-=damage;

auto fade = FadeTo::create(0.2, 40);
auto fadeBack = FadeTo::create(0.2, 0);
auto warningLayer = Director::getInstance()->getRunningScene()->getChildByTag(456);
warningLayer->runAction(Sequence::create(fade,fadeBack,NULL));
warningLayer->setVisible(true);
warningLayer->runAction(Sequence::create(fade,fadeBack,CallFunc::create(warningLayer, callfunc_selector(Player::hideWarningLayer)),NULL));

auto hpView = ((HelloWorld*)Director::getInstance()->getRunningScene()->getChildByTag(100))->getHPView();
//Rye

auto to = ProgressFromTo::create(0.5, PublicApi::hp2percent(fromHP), PublicApi::hp2percent(toHP));
hpView->runAction(to);

@@ -145,6 +148,5 @@ void Player::die()
{
_alive = false;
GameLayer::isDie=true;
//TODO: Game ended, the player is dead!
NotificationCenter::getInstance()->postNotification("ShowGameOver",NULL);
}
1 change: 1 addition & 0 deletions Classes/Player.h
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ class Player : public AirCraft
void setPosition(Point pos);
virtual bool hurt(float damage);
virtual void die();
void hideWarningLayer();
protected:
float targetAngle = 0;
Point targetPos = Point(0,0);
Loading
Oops, something went wrong.

0 comments on commit 8aa7859

Please sign in to comment.