拜托,帮助我。非常感谢。 我是一个非常新的,我正在学习通过观看一些教程视频开发Android应用程序。 我试图在日食中使用CCLOG。全部大写。 尝试打印以下信息。
CCLOG("Test String");
CCLOG("visibleSize:%.1f,%.1f",visibleSize.width,visibleSize.height);
CCLOG("origin:%.1f,%.1f",origin.x,origin.y);
它们没有出现在日食LogCat中,但是当我使用visual studio时,它们会显示在输出中。
我尝试过以下方法。但他们没有用。
将#define COCOS2D_DEBUG 1置于cpp文件中的真正顶部(高于任何#include)
在Application.mk文件中添加-DCCOCOS2D_DEBUG = 1,如下所示: APP_CPPFLAGS:= -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION = 1 -std = c ++ 11 -fsigned-char -DCCOCOS2D_DEBUG = 1
它只是cocos2d-x的HelloWorldScene
#define COCOS2D_DEBUG 1
#include "HelloWorldScene.h"
USING_NS_CC;
Scene* HelloWorld::createScene()
{
// 'scene' is an autorelease object
auto scene = Scene::create();
// 'layer' is an autorelease object
auto layer = HelloWorld::create();
// 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 ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
CCLOG("Test String");
CCLOG("visibleSize:%.1f,%.1f",visibleSize.width,visibleSize.height);
CCLOG("origin:%.1f,%.1f",origin.x,origin.y);
/////////////////////////////
// 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
auto closeItem = MenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
origin.y + closeItem->getContentSize().height/2));
// create menu, it's an autorelease object
auto menu = Menu::create(closeItem, NULL);
menu->setPosition(Vec2::ZERO);
this->addChild(menu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
// position the label on the center of the screen
label->setPosition(Vec2(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - label->getContentSize().height));
// add the label as a child to this layer
this->addChild(label, 1);
// add "HelloWorld" splash screen"
auto sprite = Sprite::create("HelloWorld.png");
// position the sprite on the center of the screen
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(sprite, 0);
return true;
}
void HelloWorld::menuCloseCallback(Ref* pSender)
{
Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
感谢您帮助我
答案 0 :(得分:0)
我在AppDelegate.h中做到了:
#ifndef _APP_DELEGATE_H_
#define _APP_DELEGATE_H_
#define COCOS2D_DEBUG 1
#include "cocos2d.h"
.. other stuff
#endif // _APP_DELEGATE_H_
并在Application.mk中:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char -DCCOCOS2D_DEBUG=1
APP_LDFLAGS := -latomic
APP_PLATFORM := android-11
APP_ABI=armeabi
#ifeq ($(NDK_DEBUG),1)
NDK_DEBUG:=1
APP_CPPFLAGS += -DCOCOS2D_DEBUG=1
APP_OPTIM := debug
#else
# APP_CPPFLAGS += -DNDEBUG
# APP_OPTIM := release
#endif
试试这个它在eclipse中适合我。如果没有,您也可以尝试添加:
android:debuggable="true"
AndroidManifest.xml中的