日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > Android >内容正文

Android

java弹弓类游戏_Android cocos2d 弹弓游戏 Catapult 源代码

發(fā)布時(shí)間:2023/12/20 Android 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java弹弓类游戏_Android cocos2d 弹弓游戏 Catapult 源代码 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

根據(jù)下面兩篇文章, 我一步步實(shí)踐, 成功讓程序在 Samsung Galaxy G2 上運(yùn)行起來(lái), 感謝這些貢獻(xiàn)者

http://www.raywenderlich.com/4756/how-to-make-a-catapult-shooting-game-with-cocos2d-and-box2d-part-1

http://mssyy2010.blog.51cto.com/4595971/847000

至于程序的設(shè)計(jì)和邏輯, 上面兩篇文章介紹得很清楚了

現(xiàn)在把源代碼提供給大家, 可以從下面的 link 下載

https://github.com/PaynePan/share_src/archive/master.zip

使用方法

1)? 解壓到cocos 目錄下一級(jí), 比如:? d: \cocos2d-2.1rc0-x-2.1.2\catapult\

catapult 下有目錄? Classes 和 proj.android

2)? import? proj.android 到 eclipse 中

3)? 在 cgywin 中 運(yùn)行 proj.android/build_native.sh, 生成 libgame.so

4)? 再在 eclipse 下編譯運(yùn)行

說(shuō)明

有幾個(gè)注意點(diǎn),說(shuō)明一下

項(xiàng)目直接使用已經(jīng)運(yùn)行的 HelloWorld 改寫過(guò)來(lái),? 主要就是改寫? HelloWorldScene.cpp, HelloWorldScene.h

1)? build_native.sh 資源文件的 copy 部分略去

coco2dx Android 最頭痛的就是 cygwin中運(yùn)行 build_native.sh 復(fù)制資源文件,? 那些操作和 win7 下的權(quán)限不兼容

所以去掉了 copy 部分, 反正這些文件已經(jīng)在 proj.android/asset中了

2) 由于 cocos2d 也在不斷改進(jìn), 現(xiàn)在代碼與原文有兩處不同

原文

CCDelayTime *delayAction = CCDelayTime::actionWithDuration(0.2f);

CCCallFunc *callSelectorAction = CCCallFunc::actionWithTarget(this, callfunc_selector(HelloWorld::resetGame));

this->runAction(CCSequence::actions(delayAction,

callSelectorAction,

NULL));

現(xiàn)在

scheduleOnce(schedule_selector(HelloWorld::resetGame),0.2f);

原文

CCTouch *touch = (CCTouch *)touches->anyObject();

CCPoint location = touch->locationInView(touch->view());

location = CCDirector::sharedDirector()->convertToGL(location);

改為

CCTouch* touch = (CCTouch*)( touches->anyObject() );

CCPoint location = touch->getLocation();

3) 在tick中 增加了再次裝彈的邏輯

if (m_bulletBody && m_bulletJoint == NULL)

{

b2Vec2 position = m_bulletBody->GetPosition();

CCPoint myPosition = this->getPosition();

CCSize screenSize = CCDirector::sharedDirector()->getWinSize();

static int count = 0;

if ( ++count % 60 ==0) {

CCLog("++++++++after x:%f, y:%f", position.x, position.y);

if ( abs(m_bullet_position.x-position.x) < 1.5f &&

abs(m_bullet_position.y-position.y) < 1.5f ) {

attachBullet();

return;

}

m_bullet_position = position;

}

// Move the camera.

if (position.x > screenSize.width / 2.0f / PTM_RATIO)

{

myPosition.x = -MIN(screenSize.width * 2.0f - screenSize.width, position.x * PTM_RATIO - screenSize.width / 2.0f);

this->setPosition(myPosition);

}

}

現(xiàn)在可以簡(jiǎn)單地玩游戲了.

總結(jié)

以上是生活随笔為你收集整理的java弹弓类游戏_Android cocos2d 弹弓游戏 Catapult 源代码的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。