'4.0.4'에 해당되는 글 1건

  1. 2014.11.25 cocos2d-x 2.1.5 갤럭시s2(4.0.4)에서 발생하는 crash문제


2.1.5버전 갤럭시s2(4.0.4)에서 버그가 발생합니다..

이유는 TTFLabel생성시 ""이면 제대로 텍스쳐를 생성을 못하여 Null값으로 들어가는 문제가 있습니다.. 이는 아주 작은 Rawdata를 생성하여 임시로 넣어주어 해결했습니다. 

-cocos2d-x 3.x에는 추가된 사항입니다.


static unsigned char cc_2x2_white_image[] = {

    // RGBA8888

    0xFF, 0xFF, 0xFF, 0xFF,

    0xFF, 0xFF, 0xFF, 0xFF,

    0xFF, 0xFF, 0xFF, 0xFF,

    0xFF, 0xFF, 0xFF, 0xFF

};


#define CC_2x2_WHITE_IMAGE_KEY  "cc_2x2_white_image"


void Sprite::setTexture(Texture2D *texture)

{

    // If batchnode, then texture id should be the same

    CCASSERT(! _batchNode || texture->getName() == _batchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode");

    // accept texture==nil as argument

    CCASSERT( !texture || dynamic_cast(texture), "setTexture expects a Texture2D. Invalid argument");


    if (NULL == texture)

    {

        // Gets the texture by key firstly.

        texture = TextureCache::getInstance()->textureForKey(CC_2x2_WHITE_IMAGE_KEY);


        // If texture wasn't in cache, create it from RAW data.

        if (NULL == texture)

        {

            Image* image = new Image();

            bool isOK = image->initWithRawData(cc_2x2_white_image, sizeof(cc_2x2_white_image), 2, 2, 8);

            CCAssert(isOK, "The 2x2 empty texture was created unsuccessfully.");


            texture = TextureCache::getInstance()->addUIImage(image, CC_2x2_WHITE_IMAGE_KEY);

            CC_SAFE_RELEASE(image);

        }

    }


    if (!_batchNode && _texture != texture)

    {

        CC_SAFE_RETAIN(texture);

        CC_SAFE_RELEASE(_texture);

        _texture = texture;

        updateBlendFunc();

    }

}

 

원본 위치 <http://discuss.cocos2d-x.org/t/cceditbox-crash-on-android-tablet/7670/15

'Mobile Programming > Cocos2d-x' 카테고리의 다른 글

Crash Reporting System  (0) 2014.12.24
cocos2d-x vs unity 2d  (0) 2014.11.25
Posted by Finebe
,