Closed LinHuan closed 12 years ago
It looks like the linker can't find the PSModalAlert::TellStatementOnLayer() function.
Is PSModalAlert.cpp in your project?
yeah, see the attachment.
i simply import the header file and call a method.
On May 18, 2012, at 6:30 PM, Philippe Chaintreuil wrote:
It looks like the linker can't find the PSModalAlert::TellStatementOnLayer() function.
Is PSModalAlert.cpp in your project?
Reply to this email directly or view it on GitHub: https://github.com/Philippe23/cocos2dx_extensions/issues/1#issuecomment-5783280
So I just took the iOS HelloWorld project from a fresh unzip of cocos2d-1.0.1-x-0.13.0-beta.zip and just drug the whole PSModalAlert folder from a git checkout I had and added the whole folder to the HelloWorld project and told XCode to copy the files to the new project.
The only code changes I made were that I changed (and split) the close button handler to use the function you were talking about:
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
PSModalAlert::TellStatementOnLayer(
"asdf",
this,
this,
callfunc_selector(HelloWorld::doQuit) );
}
void HelloWorld::doQuit()
{
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
So, it works for me on iOS -- that's what you're trying, right?
The other thing I can think of for you to check is to make sure it's being compiled: Click the HelloWorld project in the Project Navigator, then click the HelloWorld Target, then click the "Build Phases" tab, expand the "Compile Sources" and make sure PSModalAlert.cpp is listed.
of course in the project. otherwise compiler will point that out. have you received the zip file? that's my sample project.
On May 18, 2012, at 6:30 PM, Philippe Chaintreuil wrote:
It looks like the linker can't find the PSModalAlert::TellStatementOnLayer() function.
Is PSModalAlert.cpp in your project?
Reply to this email directly or view it on GitHub: https://github.com/Philippe23/cocos2dx_extensions/issues/1#issuecomment-5783280
i notice that your project uses "doQuit()" and mine use void HelloWorld::menuCloseCallback(CCObject* pSender) { CCDirector::sharedDirector()->end();
exit(0);
}
so maybe your are using earlier version of cocos?
Re: Attachment
I haven't gotten any attachments. If it's just a test-app project, you could uploaded it via a public repo on GitHub.
Re: doQuit()
That's what I meant by "and split"; I basically stuck the dialog in before the actual quitting.
sorry i don't know how to use github. anyway here is HelloWorldScene.cpp
using namespace cocos2d; using namespace CocosDenshion;
CCScene* HelloWorld::scene() { // 'scene' is an autorelease object CCScene *scene = CCScene::node();
// 'layer' is an autorelease object
HelloWorld *layer = HelloWorld::node();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; }
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::itemFromNormalImage(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback) );
pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) );
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Thonburi", 34);
// ask director the window size
CCSize size = CCDirector::sharedDirector()->getWinSize();
// position the label on the center of the screen
pLabel->setPosition( ccp(size.width / 2, size.height - 20) );
// add the label as a child to this layer
this->addChild(pLabel, 1);
// add "HelloWorld" splash screen"
CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png");
// position the sprite on the center of the screen
pSprite->setPosition( ccp(size.width/2, size.height/2) );
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
return true;
} void HelloWorld::doQuit() { CCDirector::sharedDirector()->end();
exit(0);
} void HelloWorld::menuCloseCallback(CCObject* pSender) {
PSModalAlert::TellStatementOnLayer(
"asdf",
this,
this,
callfunc_selector(HelloWorld::doQuit) );
}
and .h file:
class HelloWorld : public cocos2d::CCLayer { public: // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone virtual bool init();
// there's no 'id' in cpp, so we recommand to return the exactly class pointer
static cocos2d::CCScene* scene();
// a selector callback
virtual void menuCloseCallback(CCObject* pSender);
// implement the "static node()" method manually
LAYER_NODE_FUNC(HelloWorld);
void doQuit();
};
I think the problems is going to be in your project. Do you have a Dropbox Account? You could zip up your project and put it in there. Or you could put it on a website someplace....
Dropbox link: http://db.tt/HyY05YD
(I'm going to have to get to work soon....)
hey, there is the zipped project.
Yeah, it's your project. Sometimes or somehow XCode doesn't add the .ccp file to the list of files to compile and link when you add the files to the project.
That should fix your linking issue.
I'm not sure if you're using an older or newer version of cocos (I really got to get to work, so I can't look right now). I had to change a ccc4() to ccc4f() (or the otherway around). You're also missing the images that used for the background of the dialog and the buttons. You can just add the ones from this repo to your project. (Otherwise you'll get a crash when it can't find them.)
this is weird. i did drag the whole folder into my project. and you can find it under Resources group. could you have a check?
works now, i just deleted original png files and drag over again. thanks.
it is ok now on the simulator, but crashes on my iPad. why? in the cocos2d::CCSequence::update(float) method (line 305 of source code) error:
m_pActions[found]->startWithTarget(m_pTarget);
Thread1: EXC_BAD_ACCESS (code=1, address=0x0)
hi, please have a look at my new project here: https://www.dropbox.com/s/ua0pseilibk7fd0/psmodalalert.zip
it works on the simulator but crashes on device. you can try that out
Looks like I missed a NULL terminator on a CCSequence::actions() call.
Just checked in 48413d5d80c3117dfc9669f82c7c1d5cbad56d0b to fix.
(By the way, the minimal project really helped me find that. Thanks for posting & updating them.)
hey, I've tested out on my iPad and Kindle Fire. Works great. :P
Kindle Fire! You're in uncharted waters now! :P
hi, i encounter another issue: touches not swallowed.
i opened an issue here:
https://github.com/Philippe23/cocos2dx_extensions/issues/2
thx
On May 18, 2012, at 8:52 PM, Philippe Chaintreuil wrote:
Yeah, it's your project. Sometimes or somehow XCode doesn't add the .ccp file to the list of files to compile and link when you add the files to the project.
- Open your project
- Click on the project (at the top) in the list of files
- Click the "psmodalalert" target
- Click the "Build Phases" tab
- Expand the "Compile Sources" section
- Scroll way down to the bottom of all the files
- Click the plus
- Find the PSModalAlert.cpp file in the list, select it and click "add"
That should fix your linking issue.
I'm not sure if you're using an older or newer version of cocos (I really got to get to work, so I can't look right now). I had to change a ccc4() to ccc4f() (or the otherway around). You're also missing the images that used for the background of the dialog and the buttons. You can just add the ones from this repo to your project. (Otherwise you'll get a crash when it can't find them.)
Reply to this email directly or view it on GitHub: https://github.com/Philippe23/cocos2dx_extensions/issues/1#issuecomment-5785341
PSModalAlert::TellStatementOnLayer("asdf", this, this, callfunc_selector(HelloWorld::ps));
i have a method called ps in the HelloWorld which does nothing:
void HelloWorld::ps() { //nothing }
error message:
Undefined symbols for architecture armv7: "ZN12PSModalAlert20TellStatementOnLayerEPKcPN7cocos2d7CCLayerEPNS2_8CCObjectEMS5_FvvE", referenced from: ZN10HelloWorld4initEv in HelloWorldScene.o ld: symbol(s) not found for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Please help !!!