CCLOG不显示 [英] CCLOG not displaying

查看:217
本文介绍了CCLOG不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个代码,使用CCLog显示一个sprite的精确位置,当鼠标移动它的时候。下面是Sprite.mm类和ccTouchesEnded方法(它在HelloWorldLayer.mm类中)。 CCLog不显示消息。

I have written a code to display using CCLog the exact position of a sprite when a mousejoint moving it is released. Below is the Sprite.mm class and the ccTouchesEnded method (which is in the HelloWorldLayer.mm class). The CCLog is not displaying the message.

Sprite.mm:

Sprite.mm:

-(id)addSprite:(CCLayer *)parentLayer
                     inWorld:(b2World *)world
{
PhysicsSprite *aSprite = [PhysicsSprite spriteWithFile:@"spriteIm.png"];

aSprite.tag = 1;
[parentLayer addChild:aSprite];

b2BodyDef spriteBodyDef;
spriteBodyDef.userData = aSprite;
spriteBodyDef.type = b2_dynamicBody;
CGSize s = [CCDirector sharedDirector].winSize;
spriteBodyDef.position = [Convert toMeters:ccp(s.width * 0.25,s.height-400)];
b2FixtureDef fixtureDef;
fixtureDef.density = 0.01;
b2CircleShape circleShape;
circleShape.m_radius = aSprite.contentSize.width/2 / PTM_RATIO;
fixtureDef.shape = &circleShape;

spriteBody = world->CreateBody( &spriteBodyDef );
spriteFixture = spriteBody->CreateFixture( &fixtureDef );

[aSprite setPhysicsBody:spriteBody];

return aSprite;
}

ccTouches已结束:

ccTouchesEnded:

- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{

if (mouseJoint)
{
    for(b2Body *b = world->GetBodyList(); b; b=b->GetNext()) {
        if (b->GetUserData() != NULL) {
            CCSprite *mySprite = (CCSprite *)b->GetUserData();
            if (mySprite.tag == 1) {
                CGPoint spritePosition = mySprite.position;
                CCLOG(@"the sprite position is x:%0.2f, y:%0.2f", spritePosition.x, spritePosition.y);
            }
        }
    }        

    world->DestroyJoint(mouseJoint);
    mouseJoint = NULL;
}
}



我感觉问题是我正在访问的标签,不是真的确定。请帮忙。

I have a feeling that the issue is with the way I am accessing the tag, not really sure. Please help.

推荐答案

我认为可能会发生两件事。

There can be two things happening, in my opinion.


  1. 未达到CCLOG。这可能发生,因为sprite标记= 1 isnt设置或您要跟随的对象不与b2Body链接。用到达CCLOG的断点检查

  1. The CCLOG is not being reached. This could happen because either the sprite tag = 1 isnt set or the object you want to follow isnt linked with the b2Body. Check with a breakpoint that you reach the CCLOG

将CCLOG替换为NSLog。如果它的工作,那么你有COCOS2D_DEBUG未定义,或在0.验证您的构建设置。

Replace CCLOG with NSLog. If it works, then you have COCOS2D_DEBUG not defined, or on 0. Verify your build settings.

p>

.

\\
/*
 * if COCOS2D_DEBUG is not defined, or if it is 0 then
 *  all CCLOGXXX macros will be disabled
 *
 * if COCOS2D_DEBUG==1 then:
 *      CCLOG() will be enabled
 *      CCLOGERROR() will be enabled
 *      CCLOGINFO() will be disabled
 *
 * if COCOS2D_DEBUG==2 or higher then:
 *      CCLOG() will be enabled
 *      CCLOGERROR() will be enabled
 *      CCLOGINFO() will be enabled 
 */
#if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0
#define CCLOG(...) do {} while (0)
#define CCLOGINFO(...) do {} while (0)
#define CCLOGERROR(...) do {} while (0)

#elif COCOS2D_DEBUG == 1
#define CCLOG(...) NSLog(__VA_ARGS__)
#define CCLOGERROR(...) NSLog(__VA_ARGS__)
#define CCLOGINFO(...) do {} while (0)

#elif COCOS2D_DEBUG > 1
#define CCLOG(...) NSLog(__VA_ARGS__)
#define CCLOGERROR(...) NSLog(__VA_ARGS__)
#define CCLOGINFO(...) NSLog(__VA_ARGS__)
#endif // COCOS2D_DEBUG

这篇关于CCLOG不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆