你的位置:首页 > 软件开发 > 操作系统 > 分享一个《捕鱼》的客户端游戏

分享一个《捕鱼》的客户端游戏

发布时间:2015-03-25 23:02:27
今天一天用cocos2d做了一个捕鱼系统的demo,资源取自广为流传的android小游戏叫做年年有余,哎,无论叫做什么吧!之前是用android写的,今天一天用cocos2d从新写了一遍!大家可以用来做为学习cocos2d的demo,或者开发自己捕鱼系统的demo!  先来几张 ...

  今天一天用cocos2d做了一个捕鱼系统的demo,资源取自广为流传的android小游戏叫做年年有余,哎,无论叫做什么吧!之前是用android写的,今天一天用cocos2d从新写了一遍!大家可以用来做为学习cocos2d的demo,或者开发自己捕鱼系统的demo!

  先来几张效果图片:

  分享一个《捕鱼》的客户端游戏GameStruct.h"Fish::Fish(void){ this->fish_num = rand()%3; this->_image = NULL; this->coord_x = rand()%200; this->coord_y = rand()%200; this->image_index = 0;}Fish::~Fish(void){}bool Fish::init(){ CCSprite::init(); this->_image = CCSprite::create(fish_image[this->fish_num][0].c_str()); this->setContentSize(CCSize(60,16)); this->_image->setPosition(CCPoint(30,8)); this->addChild(this->_image); for(int i = 0;i<3;i++) { CCSprite * temp_obj = CCSprite::create(fish_image[this->fish_num][i].c_str()); CCTexture2D *hero_hit = temp_obj->getTexture(); this->_textture_vec.push_back(hero_hit); } return true;}void Fish::setCoord(int x,int y){ this->coord_x = x; this->coord_y = y;}int Fish::get_score(){ return this->image_index*2 + 1;}void Fish::wander(){ this->image_index ++; if(this->image_index >= 3) { this->image_index = 0; } this->_image->setTexture(this->_textture_vec.at(this->image_index)); float degrees = rand()/rand(); this->setRotation(degrees); int len = 6; double len_x = len*sin(degrees); double len_y = len*cos(degrees); this->coord_x += len_y; this->coord_y += len_x;}CCPoint Fish::getPoint(){ return CCPoint(coord_x,coord_y);}

原标题:分享一个《捕鱼》的客户端游戏

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录