资源简介
自己写了一个简单的小程序,其中有不足之处,望谅解,本程序只供对cocos2d-x游戏开发者学习使用;开发环境xcode4.5 coco2d-x
代码片段和文件信息
//
// Bullet.cpp
// PlantsVSZombies
//
// Created by user on 13-6-5.
//
//
#include “Bullet.h“
extern CCArray* bulletArray;
Bullet::Bullet(Plants *aplantsCCPoint pCClayer *layer)
{
plants = new Plants(aplants->plantsName);
switch (aplants->plantsName)
{
case Sunflower:
{
this->creatSunflowerBullet(player);
break;
}
case SmallPea:
case MiddlePea:
case ThreeBulletPea:
{
this->creatPeaBullet(p layer);
break;
}
default:
break;
}
}
Bullet::~Bullet()
{
delete plants;
}
void Bullet::creatSunflowerBullet(CCPoint pCClayer *layer)
{
CCSpriteframeCache *cache = CCSpriteframeCache::sharedSpriteframeCache();
cache->addSpriteframesWithFile(“Sun_default.plist“);
this->initWithSpriteframeName(“Sun-1(被拖移).tiff“);
this->setScale(0.5);
char temp[50];
CCArray *plistArray = CCArray::createWithCapacity(10);
for(int i=1;i<22;i++)
{
sprintf(temp “Sun-%i(被拖移).tiff“i);
CCSpriteframe *frame = cache->spriteframeByName(temp);
plistArray->addobject(frame);
}
CCAnimation *animation = CCAnimation::createWithSpriteframes(plistArray0.15);
CCAnimate *animate = CCAnimate::create(animation);
this->runAction(CCRepeatForever::create(animate));
CCMenuItemSprite *m = CCMenuItemSprite::create(this this this menu_selector(Bullet::collectSunshine));
m->setTag(4002);
CCMenu *menu = CCMenu::create(mNULL);
menu->setPosition(ccp(p.x+20 p.y+30));
menu->setEnabled(true);
menu->setTag(4001);
layer->addChild(menu);
CCJumpTo *jumpTo = CCJumpTo::create(1.0 ccp(menu->getPosition().x-40menu->getPosition().y-25) 30 1);
menu->runAction(jumpTo);
menu->setZOrder(1000);
}
void Bullet::moveSunshine(CCNode *senderCCMenu *m)
{
extern int SunNumber;
SunNumber = SunNumber + 50;
m->removeFromParent();
}
void Bullet::collectSunshine(CCNode *sender)
{
sender->stopAllActions();
CCMoveTo *moveTo = CCMoveTo::create(1.0 ccp(60 320));
CCCallFuncND *funcND = CCCallFuncND::create(this callfuncND_selector(Bullet::moveSunshine) sender->getParent());
CCSequence *seq = CCSequence::create(moveTofuncNDNULL);
sender->getParent()->runAction(seq);
}
void Bullet::creatPeaBullet(CCPoint pCClayer *layer)
{
bulletArray->retain();
position = p;
CCSpriteframeCache *cache = CCSpriteframeCache::sharedSpriteframeCache();
cache->addSpriteframesWithFile(“PeashooterBullet_default.plist“);
this->initWithSpriteframeName(“PeashooterBullet-1(被拖移).tiff“);
this->setPosition(ccp(p.x+10 p.y+10));
this->setScale(0.5);
bulletArray->addobject(this);//把子弹添加到数组里边
layer->addChild(this);
float distance = 500-this->getPosition().x;
float time = distance/BulletSpeedRatio;
CCMoveTo *moveTo = CCMoveTo::create(time ccp(500this->getPosition().y));
this->runAction(mov
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-11-16 14:29 PlantsVSZombies\
文件 6148 2013-11-16 14:29 PlantsVSZombies\.DS_Store
目录 0 2013-11-21 08:42 __MACOSX\
目录 0 2013-11-21 08:42 __MACOSX\PlantsVSZombies\
文件 82 2013-11-16 14:29 __MACOSX\PlantsVSZombies\._.DS_Store
目录 0 2013-11-21 08:40 PlantsVSZombies\PlantsVSZombies\
文件 6148 2013-11-14 09:03 PlantsVSZombies\PlantsVSZombies\.DS_Store
目录 0 2013-11-21 08:42 __MACOSX\PlantsVSZombies\PlantsVSZombies\
文件 82 2013-11-14 09:03 __MACOSX\PlantsVSZombies\PlantsVSZombies\._.DS_Store
文件 4732 2013-11-19 09:45 PlantsVSZombies\PlantsVSZombies\Bullet.cpp
文件 171 2013-11-19 09:45 __MACOSX\PlantsVSZombies\PlantsVSZombies\._Bullet.cpp
文件 898 2013-11-15 20:00 PlantsVSZombies\PlantsVSZombies\Bullet.h
文件 171 2013-11-15 20:00 __MACOSX\PlantsVSZombies\PlantsVSZombies\._Bullet.h
目录 0 2013-11-19 20:03 PlantsVSZombies\PlantsVSZombies\Classes\
文件 4994 2013-11-19 20:03 PlantsVSZombies\PlantsVSZombies\Classes\AppDelegate.cpp
目录 0 2013-11-21 08:42 __MACOSX\PlantsVSZombies\PlantsVSZombies\Classes\
文件 171 2013-11-19 20:03 __MACOSX\PlantsVSZombies\PlantsVSZombies\Classes\._AppDelegate.cpp
文件 1183 2013-11-12 12:00 PlantsVSZombies\PlantsVSZombies\Classes\AppDelegate.h
文件 171 2013-11-12 12:00 __MACOSX\PlantsVSZombies\PlantsVSZombies\Classes\._AppDelegate.h
文件 331 2013-11-20 11:15 PlantsVSZombies\PlantsVSZombies\Data.h
文件 171 2013-11-20 11:15 __MACOSX\PlantsVSZombies\PlantsVSZombies\._Data.h
文件 1747 2013-11-19 19:42 PlantsVSZombies\PlantsVSZombies\FailScene.cpp
文件 171 2013-11-19 19:42 __MACOSX\PlantsVSZombies\PlantsVSZombies\._FailScene.cpp
文件 442 2013-11-19 19:41 PlantsVSZombies\PlantsVSZombies\FailScene.h
文件 171 2013-11-19 19:41 __MACOSX\PlantsVSZombies\PlantsVSZombies\._FailScene.h
文件 12453 2013-11-19 09:36 PlantsVSZombies\PlantsVSZombies\failscene.png
文件 177 2013-11-19 09:36 __MACOSX\PlantsVSZombies\PlantsVSZombies\._failscene.png
文件 4507 2013-11-16 13:34 PlantsVSZombies\PlantsVSZombies\FinalWave.png
文件 177 2013-11-16 13:34 __MACOSX\PlantsVSZombies\PlantsVSZombies\._FinalWave.png
文件 229 2013-11-08 08:26 PlantsVSZombies\PlantsVSZombies\FlagMeterLevelProgress.png
文件 172 2013-11-08 08:26 __MACOSX\PlantsVSZombies\PlantsVSZombies\._FlagMeterLevelProgress.png
............此处省略1846个文件信息
- 上一篇:STM32F407+FREERTOS模板程序
- 下一篇:vc助手for vs2013
相关资源
- VRML虚拟现实应用技术11679 源程序 ra
-
WebGIS之Openla
yers全面解析源码+数据库 - QmlBook_PDF_中文+英文+源码
- Spring Boot 2企业应用实战 源码
- 二手房信息管理软件源码房产系统
- NodeJS实战搭建博客_源码
- GridCtrl控件源码及Demo
- 莱昂氏UNIX源代码分析全本.pdf
- OpenGL三维图形系统开发与实用技术.
- SSH2三大框架的整合详解()
- RC522 单片机 上位机 下位机源码
- SCOMMV23精修版(CoM口源码)
- 《DirectX+游戏开发终极指南》exe电子书
- 几十个微信H5小游戏完整源码
- 航空后勤资产管理系统后端实训源码
- Spring Boot 实战,中文版+英文版+源码
- C语音学习算法100例源码,程序,工具
- 精典源码Delphi054:海盗远控源码.rar
- 网页版Tom猫
- 稀疏光流算法程序
- 小清新优秀文章新闻博客类织梦dede
- GMT 0001-2012 祖冲之序列密码算法 + 官方
- .net餐饮管理系统源码
- 房贷计算器 安卓源码
- 有关绘图类chartctrl的说明,源码和
- 在线文档管理系统源码
- XTP库文件 编译远控源码必备
- TowerDefense cocos2d-x
- TestStand工业自动化管理 源码
- Unity3D贪吃蛇源码
评论
共有 条评论