Return to Cocos2dx Playback Library

How reskin to another textures?

Questions related to Cocos2dx playback library should be asked here.

How reskin to another textures?

Postby mishok043 » October 10th, 2016, 10:59 am

Hello.
How I can reskin some parts of a flash-objects to another textures (for example, for an armed skin)?
I have read that for this I can use a function GAFAsset::getCustomRegion(name), but after I get a new texture, how can I set it for some part of an animation?
Thank you for helping.
User avatar
mishok043
 
Posts: 1
Joined: October 10th, 2016, 10:52 am

Re: How reskin to another textures?

Postby Jonathan Reis » November 17th, 2016, 4:28 am

In the old version I did like this:
But now it does not work anymore, if you can solve it, please come back here and post the code.

Code: Select all

    p_GAF_Corpo = GAFEngine::getInstance()->getAsset()->createObjectAndRun();
    addChild(p_GAF_Corpo, 1, "GAF");
   
    ChangeSprites("ANIM_CABECA", "DOG_3_CABECA");
    ChangeSprites("ANIM_TRONCO", "DOG_3_TRONCO");
    ChangeSprites("ANIM_PE_DIR", "PEGRANDE_PE_DIR");
    ChangeSprites("ANIM_PE_ESQ", "PEGRANDE_PE_ESQ");


void Hero::ChangeSprites(const char * original, const char * novo)
{
    //Trocando Sprites dinamicamente:
    unsigned int _EXISTENTE_ID = p_GAF_Corpo->objectIdByObjectName(original);
    unsigned int _NOVO_ID = p_GAF_Corpo->objectIdByObjectName(novo);
   
    if ((_EXISTENTE_ID != IDNONE) && (_NOVO_ID != IDNONE)) {
       
        auto _EXISTENTE = p_GAF_Corpo->subObjectForInnerObjectId(_EXISTENTE_ID);
        auto _NOVO = p_GAF_Corpo->subObjectForInnerObjectId(_NOVO_ID);
       
        auto spriteFrame = _NOVO->getSpriteFrame();
        auto sprite = Sprite::createWithSpriteFrame(spriteFrame);
        sprite->setAnchorPoint( _NOVO->getAnchorPoint() );
        sprite->setPosition(_EXISTENTE->getContentSize().width / 2, _EXISTENTE->getContentSize().height / 2);
       
        _EXISTENTE->addChild(sprite);
       
    } else {
        CCLOG("===> I did not find it!");
    }
}
User avatar
Jonathan Reis
 
Posts: 14
Joined: July 14th, 2014, 11:32 am

Re: How reskin to another textures?

Postby Dmitry Bushtets » November 17th, 2016, 7:54 am

Hello guys!

Sorry for late response. In fact we didn't support changing inner parts of animation in GAF5. You can try to add some different animations to keyframes and switch by
Code: Select all
GAFObject::playSequence
between them.

@Jonathan Reis
You can try
Code: Select all
GAFObject::getObjectByName
instead two methods
Code: Select all
objectIdByObjectName && subObjectForInnerObjectId
User avatar
Dmitry Bushtets
 
Posts: 86
Joined: August 11th, 2014, 1:31 am

Return to Cocos2dx Playback Library

Who is online

Users browsing this forum: No registered users and 1 guest