Hi team.
i currenly build my application from GitHub version [7442c0d7321cf379f303e942b65ad1bbe2916209]
and looks like there is a error for Android
I/DEBUG ( 3561): r0 00000000 r1 43f00000 r2 43900000 r3 0c000000
I/DEBUG ( 3561): r4 400ebbc8 r5 7a1723a8 r6 00000298 r7 7a6b1390
I/DEBUG ( 3561): r8 00000002 r9 7ad84e34 sl 7aea5da0 fp 77a0105c
I/DEBUG ( 3561): ip 00000000 sp 78e0f820 lr 7752820c pc 772072e8 cpsr 80070030
I/DEBUG ( 3561):
I/DEBUG ( 3561): backtrace:
I/DEBUG ( 3561): #00 pc 0042f2e8 /data/app-lib/net.orionlab.netshooter-1/libMyGame.so (HelloWorld::onMyTouchEnded(cocos2d::Touch*, cocos2d::Event*)+39)
I/DEBUG ( 3561): #01 pc 00750208 /data/app-lib/net.orionlab.netshooter-1/libMyGame.so (cocos2d::GLView::getVisibleSize() const+80)
I/DEBUG ( 3561):
I/DEBUG ( 3561): stack:
I/DEBUG ( 3561): 78e0f7e0 00037ea1
I/DEBUG ( 3561): 78e0f7e4 4030e8e7 /system/lib/libgui.so (android::Surface::queueBuffer(ANativeWindowBuffer*, int)+302)
I/DEBUG ( 3561): 78e0f7e8 79746b68
I/DEBUG ( 3561): 78e0f7ec 7ad5e028
I/DEBUG ( 3561): 78e0f7f0 00001002
I/DEBUG ( 3561): 78e0f7f4 00000000
I/DEBUG ( 3561): 78e0f7f8 00000000
I/DEBUG ( 3561): 78e0f7fc 00000000
I/DEBUG ( 3561): 78e0f800 00000000
I/DEBUG ( 3561): 78e0f804 00000000
I/DEBUG ( 3561): 78e0f808 78e0f86c [stack:3494]
I/DEBUG ( 3561): 78e0f80c 7a1723a8
I/DEBUG ( 3561): 78e0f810 00000298
I/DEBUG ( 3561): 78e0f814 7755099c /data/app-lib/net.orionlab.netshooter-1/libMyGame.so (cocos2d::Director::getVisibleSize() const+32)
I/DEBUG ( 3561): 78e0f818 400ebbc8
I/DEBUG ( 3561): 78e0f81c 772072e7 /data/app-lib/net.orionlab.netshooter-1/libMyGame.so (HelloWorld::onMyTouchEnded(cocos2d::Touch*, cocos2d::Event*)+38)
I/DEBUG ( 3561): #00 78e0f820 00004024
I/DEBUG ( 3561): 78e0f824 79748ee0
I/DEBUG ( 3561): 78e0f828 00000000
I/DEBUG ( 3561): 78e0f82c 79b79008
I/DEBUG ( 3561): 78e0f830 00000000
I/DEBUG ( 3561): 78e0f834 75dda120 /system/lib/libMali.so
I/DEBUG ( 3561): 78e0f838 00000007
I/DEBUG ( 3561): 78e0f83c 00000008
I/DEBUG ( 3561): 78e0f840 00000008
I/DEBUG ( 3561): 78e0f844 00000008
I/DEBUG ( 3561): 78e0f848 78e0f86c [stack:3494]
I/DEBUG ( 3561): 78e0f84c a49f6ff2
I/DEBUG ( 3561): 78e0f850 0000000b
I/DEBUG ( 3561): 78e0f854 77558ddc /data/app-lib/net.orionlab.netshooter-1/libMyGame.so (std::_Hashtable<std::string, std::pair<std::string const, cocos2d::EventDispatcher::EventListenerVector*>, std::allocator<std::pair<std::string const, cocos2d::EventDispatcher::EventListenerVector*> >, std::__detail::_Select1st, std::equal_to<std::string>, std::hash<std::string>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_find_before_node(unsigned int, std::string const&, unsigned int) const+84)
I/DEBUG ( 3561): 78e0f858 88548344
I/DEBUG ( 3561): 78e0f85c 77a019b0
Header
#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__
#include "cocos2d.h"
using namespace cocos2d;
class HelloWorld : public Layer {
public:
static Scene* createScene();
virtual bool init();
CREATE_FUNC(HelloWorld);
bool onMyTouchBegan(Touch *touch, Event *unused_event);
void onMyTouchEnded(Touch *touch, Event *unused_event);
};
#endif
Implementation
#include "HelloWorldScene.h"
Scene* HelloWorld::createScene() {
auto scene = Scene::create();
auto layer = HelloWorld::create();
scene->addChild(layer);
return scene;
}
bool HelloWorld::init() {
if (!Layer::init()) {
return false;
}
auto listener = EventListenerTouchOneByOne::create();
listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onMyTouchBegan, this);
listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onMyTouchEnded, this);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
return true;
}
bool HelloWorld::onMyTouchBegan(cocos2d::Touch *touch, cocos2d::Event *unused_event) {
return true;
}
void HelloWorld::onMyTouchEnded(cocos2d::Touch *touch, cocos2d::Event *unused_event) {
//this->removeChildByTag(100);
Size winSize = Director::getInstance()->getVisibleSize(); // <<< CRASH HERE >>>
std::string lblText = StringUtils::format("Touch(%f,%f) WinSize(%f,%f)",
touch->getLocation().x, touch->getLocation().y,
winSize.width, winSize.height);
Label *lblPos = Label::createWithTTF(lblText, "fonts/arial.ttf", 35);
lblPos->setPosition(Vec2(winSize.width/2, winSize.height/2));
this->addChild(lblPos, 100, 100);
}
