//
// GameScene.cpp
// FireDemo
//
// Created by LiuYanghui on 13-2-4.
//
//
#include "GameScene.h"
#include "Bullet.h"
GameScene::GameScene(){
}
GameScene::~GameScene(){
}
CCScene* GameScene::scene(){
CCScene* scene = CCScene::create();
GameScene* layer = GameScene::create();
scene->addChild(layer);
return
scene;
}
bool
GameScene::init(){
if
(!CCLayer::init()) {
return
false
;
}
initData();
return
true
;
}
void
GameScene::initData(){
winSize = CCDirector::sharedDirector()->getWinSize();
CCSprite* mainBg = CCSprite::create(
"bg.jpg"
);
mainBg->setPosition(ccp(winSize.width*.5,winSize.height*.5));
addChild(mainBg);
CCSprite* tank = CCSprite::create(
"tank.png"
);
tank->setPosition(ccp(winSize.width*.5,winSize.height*.8));
addChild(tank);
//创建子弹对象
m_bullet = Bullet::create();
m_bullet->setPosition(winSize.width*.5,winSize.height*.8);
addChild(m_bullet);
setTouchEnabled(
true
);
}
void
GameScene::registerWithTouchDispatcher(
void
){
CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(
this
, 0,
true
);
}
bool
GameScene::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
//每次点击添加一个新子弹
m_bullet->addNewBullet();
return
true
;
}
void
GameScene::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent)
{
}
void
GameScene::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
}
void
GameScene::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent)
{
}
联系客服