j2me BUG

  • G1_634632
    了解作者
  • 198.5KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-01 02:32
    上传日期
NULL 博文链接:https://buerkai.iteye.com/blog/1119025
Man.rar
  • Man
  • win32
  • res
  • Man.ico
    1.1KB
  • Man.rc
    2.2KB
  • resource.h
    461B
  • main.cpp
    400B
  • main.h
    280B
  • Man.win32.vcproj.user
    484B
  • Resources
  • joystick1.png
    2.4KB
  • background.png
    162.7KB
  • bullet.png
    2.7KB
  • explosion.png
    1.1KB
  • explosion.WAV
    13.8KB
  • plane.png
    2.8KB
  • joystick2.png
    1.2KB
  • Man.win32.vcproj.goldlion-PC.goldlion.user
    1.4KB
  • Man.win32.vcproj
    6.8KB
  • Classes
  • FlyScene.cpp
    9KB
  • AppDelegate.cpp
    2.9KB
  • FlyScene.h
    1.3KB
  • TitleScene.h
    746B
  • GameOverScene.cpp
    4.6KB
  • tools.cpp
    1.3KB
  • AppDelegate.h
    1.1KB
  • tools.h
    524B
  • SettingScene.h
    682B
  • SettingScene.cpp
    3.3KB
  • global.h
    186B
  • TitleScene.cpp
    3.7KB
  • global.cpp
    101B
  • GameOverScene.h
    678B
内容介绍
#include "FlyScene.h" #include "TitleScene.h" #include "GameOverScene.h" #include "global.h" #include "tools.h" using namespace cocos2d; bool FlyScene::init() { bool bRet = false; do { CC_BREAK_IF(! CCLayer::init()); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCSprite *joystick1=CCSprite::spriteWithFile("joystick1.png"); joystick1->setOpacity(191); joystick1->setAnchorPoint(ccp(0,0)); joystick1->setPosition(ccp(0,0)); radius=joystick1->getContentSize().width/2; centre=ccp(radius,radius); this->addChild(joystick1,1); joystick=CCSprite::spriteWithFile("joystick2.png"); joystick->setPosition(ccp(centre.x,centre.y)); this->addChild(joystick,2); //返回 CCMenuItemFont::setFontSize(22); CCMenuItemFont::setFontName("American Typewriter"); std::string str = ""; str="返回"; #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) GBKToUTF8(str,"gb2312","utf-8"); #endif CCMenuItemFont* systemMenu = CCMenuItemFont::itemFromString(str.c_str(),this,menu_selector(FlyScene::menuReturnCallback)); CCMenu* mn = CCMenu::menuWithItems(systemMenu,NULL); mn->setPosition(ccp(0,0)); systemMenu->setAnchorPoint(ccp(1,0)); systemMenu->setPosition(ccp(s.width,0)); this->addChild(mn,1); //飞机 CCTexture2D *texture=CCTextureCache::sharedTextureCache()->addImage("plane.png"); plane = CCSprite::spriteWithTexture(texture); plane->setPosition(ccp(s.width/2,s.height/2)); this->addChild(plane,0); //开启触摸 this->setIsTouchEnabled(true); //开启逻辑 this->schedule(schedule_selector(FlyScene::flying)); this->schedule(schedule_selector(FlyScene::createBullet)); this->schedule(schedule_selector(FlyScene::checkBullet)); this->schedule(SEL_SCHEDULE(&FlyScene::saveTime),1); //清零数据 isFlying=false; speedX=speedY=0; g_gameTime=0; bRet = true; }while(0); return bRet; } cocos2d::CCScene* FlyScene::scene() { CCScene * scene = NULL; do { // 'scene' is an autorelease object scene = CCScene::node(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object FlyScene *layer = FlyScene::node(); CC_BREAK_IF(! layer); // add layer as a child to scene scene->addChild(layer); } while (0); // return the scene return scene; } void FlyScene::menuReturnCallback( CCObject *pSender ) { CCScene * scene=TitleScene::scene(); CCDirector::sharedDirector()->replaceScene(CCTransitionFlipX::transitionWithDuration(1.2f,scene)); } void FlyScene::ccTouchesBegan( CCSet *pTouches, CCEvent *pEvent ) { CCTouch *touch = (CCTouch*)pTouches->anyObject(); CCPoint location = touch->locationInView(touch->view()); CCPoint convertedLocation = CCDirector::sharedDirector()->convertToGL(location); CCRect rect=joystick->boundingBox(); if (CCRect::CCRectContainsPoint(rect,convertedLocation)) { isFlying=true; } } void FlyScene::ccTouchesMoved( CCSet *pTouches, CCEvent *pEvent ) { CCTouch *touch = (CCTouch*)pTouches->anyObject(); CCPoint location = touch->locationInView(touch->view()); CCPoint convertedLocation = CCDirector::sharedDirector()->convertToGL(location); bool inRange=pow(centre.x-convertedLocation.x,2)+pow(centre.y-convertedLocation.y,2)<pow(radius,2); if(isFlying&&inRange) { CCPoint position=plane->getPosition(); joystick->setPosition(convertedLocation); float radius1=radius*2/6;//十字键中心区的内切圆半径 float side=radius*2/3;//九宫格中一个格子的边长 //我们使用海伦公式来计算面积,进而判断十字键中心区的精确方向 //向上 if(triangleContainPoint(centre.x,centre.y,centre.x-radius1,centre.y+radius1,centre.x+radius1,centre.y+radius1,convertedLocation.x,convertedLocation.y) ||CCRect::CCRectContainsPoint(CCRectMake(centre.x-radius1,centre.y+radius1,side,side),convertedLocation)) { speedX=0; speedY=1; } //向下 else if(triangleContainPoint(centre.x,centre.y,centre.x-radius1,centre.y-radius1,centre.x+radius1,centre.y-radius1,convertedLocation.x,convertedLocation.y) ||CCRect::CCRectContainsPoint(CCRectMake(centre.x-radius1,centre.y-radius1-side,side,side),convertedLocation)) { speedX=0; speedY=-1; } //向左 else if(triangleContainPoint(centre.x,centre.y,centre.x-radius1,centre.y+radius1,centre.x-radius1,centre.y-radius1,convertedLocation.x,convertedLocation.y) ||CCRect::CCRectContainsPoint(CCRectMake(centre.x-radius1-side,centre.y-radius1,side,side),convertedLocation)) { speedX=-1; speedY=0; } //向右 else if (triangleContainPoint(centre.x,centre.y,centre.x+radius1,centre.y+radius1,centre.x+radius1,centre.y-radius1,convertedLocation.x,convertedLocation.y) ||CCRect::CCRectContainsPoint(CCRectMake(centre.x+radius1+side,centre.y-radius1,side,side),convertedLocation)) { speedX=1; speedY=0; } //右上 else if(convertedLocation.x-centre.x>0&&convertedLocation.y-centre.y>0) { speedX=0.7f; speedY=0.7f; } //左上 else if (convertedLocation.x-centre.x<0&&convertedLocation.y-centre.y>0) { speedX=-0.7f; speedY=0.7f; } //左下 else if (convertedLocation.x-centre.x<0&&convertedLocation.y-centre.y<0) { speedX=-0.7f; speedY=-0.7f; } //右下 else if (convertedLocation.x-centre.x>0&&convertedLocation.y-centre.y<0) { speedX=0.7f; speedY=-0.7f; } } } void FlyScene::ccTouchesEnded( CCSet *pTouches, CCEvent *pEvent ) { isFlying=false; joystick->setPosition(centre); speedX=speedY=0; } void FlyScene::flying( cocos2d::ccTime dt ) { if (isFlying&&(speedX!=0||speedY!=0)) { CCPoint position=ccp(plane->getPosition().x+speedX,plane->getPosition().y+speedY); CCSize size=CCDirector::sharedDirector()->getWinSize(); CCRect rect=CCRectMake(0,0,size.width,size.height); if(CCRect::CCRectContainsPoint(rect,position)) { plane->setPosition(position); } } } void FlyScene::createBullet( cocos2d::ccTime dt ) { if (bullets.size()>g_bulletNum) { return; } CCTexture2D *texture=CCTextureCache::sharedTextureCache()->addImage("bullet.png"); CCSprite *bullet=CCSprite::spriteWithTexture(texture); this->addChild(bullet,0); bullets.push_back(bullet); float x,y; int speedX,speedY; CCSize size=CCDirector::sharedDirector()->getWinSize(); int entrance=abs(rand()%4); switch(entrance) { case 0://上侧飞入 x=abs(rand()%(int)size.width); y=size.height-bullet->boundingBox().size.height; speedX=rand()%3; speedY=(abs(rand()%3+1))*-1; break; case 1://下侧飞入 x=abs(rand()%(int)size.width); y=bullet->boundingBox().size.height; speedX=rand()%3; speedY=abs(rand()%3+1); break; case 2://左侧飞入 x=bullet->boundingBox().size.width; y=abs(rand()%(int)size.height); speedX=abs(rand()%3+1); speedY=rand()%3; break; case 3://右侧飞入 x=size.width-bullet->boundingBox().size.width; y=abs(rand()%(int)size.height); speedX=abs(rand()%3+1)*-1; speedY=rand()%3; break; } CCActionInterval *action=CCMoveBy::actionWithDuration(0.1f,ccp(speedX,speedY)); bullet->setPosition(ccp(x,y)); bullet->runAction(CCRepeatForever::actionWithAction(action)); } void FlyScene::checkBullet(cocos2d::ccTime dt) { if (!plane->getIsVisible()) { return; } CCSize size=CCDirector::sharedDirector()->getWinSize(); CCRect screen=CCRectMake(0,0,size.width,size.height); CCRect planeBox=plane->boundingBox(); for (std::vector<cocos2d::CCSprite*>::iterator bitr=bullets.begin(); bitr != bullets.end();) { CCSprite *bullet =*bitr; CCPoint position=bullet->getPosition(); CCRect bulletBox=bullet->boundingBox(); if (CCRect::CCRectIntersectsRect(planeBox,bulletBox)) { this->removeChild(bullet, true); bitr=bullets.erase(bitr); plane->setIsVisible(false); CCTexture2D *texture=CCTextureCache::sharedTextureCache()->addImage("explosion.png"); CCAnimation *animation = CCAnimation::ani
评论
    相关推荐
    • ext BUG修复补丁
      NULL 博文链接:https://sbfeeq.iteye.com/blog/905414
    • 经典Bug参考
      NULL 博文链接:https://lihbobo.iteye.com/blog/587261
    • j2me BUG
      NULL 博文链接:https://buerkai.iteye.com/blog/1119025
    • IE-bug
      NULL 博文链接:https://citi21558541.iteye.com/blog/1097974
    • j2me BUG
      NULL 博文链接:https://buerkai.iteye.com/blog/1119025
    • unidoc_image_bug:重现https
      Unidoc图片错误 参见 跑步 $ go run pdf_add_image_to_page.go blank.pdf -1 quince.jpg 0 0 320 output.pdf 结果 $ ls -la 4,911 Apr 2 16:44 blank.pdf 1,561,519 Apr 2 16:30 quince.jpg 18,745,526 Apr 2 16:...
    • android socketio fix https bug
      android socketio.修改Gottox/socket.io-java-client中https 不能连接服务器的问题。
    • jbpm bug
      NULL 博文链接:https://lieyan133.iteye.com/blog/616572
    • artDialog修改bug
      NULL 博文链接:https://yi5414289.iteye.com/blog/1714279
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
      guassdb100在redhat上安装包,单机部署的包,安装步骤请看我的文中介绍,经过大量实验搭建总结出来的文档