quick-cocos2d-x想制作一个退出游戏的按钮,怎么实现
答案:2 悬赏:10 手机版
解决时间 2021-03-04 13:47
- 提问者网友:我们很暧昧
- 2021-03-04 02:28
quick-cocos2d-x想制作一个退出游戏的按钮,怎么实现
最佳答案
- 五星知识达人网友:鱼忧
- 2021-03-04 03:24
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.", "Alert");
return;
#endif
Director::getInstance()->end();//windows平台和安卓主要调用这一句
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.", "Alert");
return;
#endif
Director::getInstance()->end();//windows平台和安卓主要调用这一句
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
全部回答
- 1楼网友:撞了怀
- 2021-03-04 04:03
function mainscene:addbackevent()
if device.platform == "android" then
self.touchlayer = display.newlayer()
self.touchlayer:addnodeeventlistener(cc.keypad_event, function(event)
if event.key == "back" then
--ccdirector:shareddirector():endtolua()
local javaclassname = "com/cocos2dx/testgame/testgame"
local javamethodname = "exit"
luaj.callstaticmethod(javaclassname, javamethodname)
end
end)
self.touchlayer:setkeypadenabled(true)
self:addchild(self.touchlayer)
end
end
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯