Cocos2d-x游戏《雷电大战》开源啦!要源码要资源快快来~~

写在前面的话:这是笔者开发的第二个小游戏《雷电大战》,之前就过这个游戏和《赵云要格斗》一样,最终将会开源。由于自己的一些个人原因。这个游戏还没有完成,但是许多网友都过来寻求代码或资源,本着开源的精神,笔者今天将它们共享给出大家。
注:目前游戏还没有完成,代码全是笔者原创,资源有一部分原创,有一部分网上搜集。

若是觉得本项目对你有用,那么请给辛苦的笔者的GitHub右上角Star一颗星星!不胜感激~~~~

下载地址

https://github.com/appleappleapple/GameOfShooting

游戏专辑

http://blog.csdn.net/column/details/cocos2dxforgame.html

专辑目录

Cocos2d-x《雷电大战》(1)-双层地图无限滚动
Cocos2d-x《雷电大战》(2)-精灵随手指移动,你点哪我走哪!
Cocos2d-x《雷电大战》(3)-子弹无限发射
Cocos2d-x《雷电大战》(4)-策略模式实现不同子弹切换!!
Cocos2d-x《雷电大战》(5)-单例模式英雄飞机闪亮登场!
Cocos2d-x《雷电大战》(6) 智能敌机AI来袭–飞行路径算法设计与实现(上)
Cocos2d-x《雷电大战》(6) 智能敌机AI来袭–飞行路径算法设计与实现(下)

工程目录

雷电大战工程代码目录雷电大战工程代码目录详细

简要介绍

《雷电大战》是一框射击类游戏,代码全部是本人原创,资源图片部分原创,部分网上搜集。游戏的具体代码实现过程以及游戏效果请看笔者博客地址:http://blog.csdn.net/evankaka

项目环境

Cocos2d-x版本:3.3以上 (至少 3.X)
开发环境:VS2013 + WIN7
游戏专辑地址:http://blog.csdn.net/Evankaka/article/category/2922463

项目

1.打开方式

找到proj.win32文件夹下,test.sln。然后使用VS2013打开即可,同时配置Cocos2d-x3.x版本,2.x是编译不通过的!

2.代码路径

主目录Classes文件夹下,具体文件可看博文内容

3.资源路径

主目录Resources文件夹下

部分效果

这里写图片描述这里写图片描述
这里写图片描述这里写图片描述

其它Cocos2d-x项目

《赵云要格斗》

cocos2dx 雷电MoonWarriors_游戏源码 #include "GameLayer.h" #include "SimpleAudioEngine.h" #include "Bullet.h" #include "Resource.h" #include "Config.h" #include "Enemy.h" #include "Effect.h" #include "GameOver.h" #include "PauseLayer.h" using namespace cocos2d; using namespace CocosDenshion; bool isPaused = false; GameLayer::GameLayer():m_state(statePlaying),m_time(0),m_ship(NULL),m_backSky(NULL),m_backSkyHeight(0),m_backSkyRe(NULL),m_backTileMap(NULL),m_backTileMapHeight(0),m_backTileMapRe(NULL),m_isBackSkyReload(false),m_isBackTileReload(false),m_lbScore(NULL),m_lifeCount(NULL), m_tempScore(0) { } GameLayer::~GameLayer() { if (m_levelManager) { delete m_levelManager; } play_bullet->release(); enemy_bullet->release(); enemy_items->release(); } bool GameLayer::init() { if (!CCLayer::init()) { return false; } // 开启触摸 this->setTouchEnabled(true); // 创建数组,需要retain一下 play_bullet = CCArray::create(); play_bullet->retain(); enemy_bullet = CCArray::create(); enemy_bullet->retain(); enemy_items = CCArray::create(); enemy_items->retain(); m_state = statePlaying; Enemy::sharedEnemy(); Effect::sharedExplosion(); Config::sharedConfig()->resetConfig(); winSize = CCDirector::sharedDirector()->getWinSize(); m_levelManager = new LevelManager(this); //初始化背景 initBackground(); m_screenRec = CCRectMake(0, 0, winSize.width, winSize.height + 10); // score m_lbScore = CCLabelBMFont::create("Score:0", s_arial14_fnt); m_lbScore->setAnchorPoint(ccp(1, 0)); m_lbScore->setAlignment(kCCTextAlignmentRight); addChild(m_lbScore, 1000); m_lbScore->setPosition(winSize.width - 5, winSize.height - 30); // ship life CCTexture2D *shipTexture = CCTextureCache::sharedTextureCache()->addImage(s_ship01); CCSprite *life = CCSprite::createWithTexture(shipTexture, CCRectMake(0, 0, 60, 38)); life->setScale(0.6); life->setPosition(ccp(30,winSize.height-23)); addChild(life, 1, 5); // ship life count char lifecount[2]; sprintf(lifecount, "%d",Config::sharedConfig()->getLifeCount()); m_lifeCount = CCLabelTTF::create(lifecount, "Arial", 20); m_lifeCount->setPosition(ccp(60, winSize.height-20)); m_lifeCount->setColor(ccc3(255,0, 0)); addChild(m_lifeCount, 1000); // ship m_ship = Ship::create(); addChild(m_ship, m_ship->getZoder(), 1001); CCMenuItemImage *pause = CCMenuItemImage::create("pause.png", "pause.png", this, menu_selector(GameLayer::doPause)); pause->setAnchorPoint(ccp(1, 0)); pause->setPosition(ccp(winSize.width, 0)); CCMenu *menu = CCMenu::create(pause, NULL); menu->setAnchorPoint(ccp(0, 0)); addChild(menu, 1, 10); menu->setPosition(CCPointZero); // 调 update函数 scheduleUpdate(); // 每秒调一次 scoreCounter函数 schedule(schedule_selector(GameLayer::scoreCounter), 1); if (Config::sharedConfig()->getAudioState()) { SimpleAudioEngine::sharedEngine()->playBackgroundMusic(s_bgMusic, true); } return true; } void GameLayer::update(float dt) { if (m_state == statePlaying) { checkIsCollide(); removeInactiveUnit(dt); checkIsReborn(); updateUI(); } } void GameLayer::scoreCounter() { if (m_state == statePlaying) { m_time++; m_levelManager->loadLevelResource(m_time); } } void GameLayer::checkIsCollide() { CCObject *units; CCObject *bullets; CCObject *enemybs; CCARRAY_FOREACH(enemy_items, units) { UnitSprite *enemy = dynamic_cast<UnitSprite*>(units); CCARRAY_FOREACH(play_bullet, bullets) { UnitSprite *bullet = dynamic_cast<UnitSprite*>(bullets); if (this->collide(enemy, bullet)) { enemy->hurt(); bullet->hurt(); } if (!(m_screenRec.intersectsRect(bullet->boundingBox()))) { bullet->destroy(); } }
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值