第9月第26天 pairs和ipairs cocos2dx 动画

1.

a={ ip = "127.0.0.1", port = 6789 }

for i,v in pairs(a) do

print(i,v)

end

 

a={1}

for i,v in ipairs(a) do

print(i,v)

end

http://blog.csdn.net/witch_soya/article/details/7556595

 

2.

 

/*
怪物伤害数字动画特效
*/
void SpiritsMonster::showattcknumber(int attcknum,CCSprite* monster)
{
    if(attcknum>0)
    {
        //解析数值转化为2中格式字符串string和CCString;
        char char_attckmun[100] = {0};
        sprintf(char_attckmun,"%d",attcknum,char_attckmun);
        //这个主要用途拿来作为字符和int之间的相互转换
        CCString* numberstr = CCString::create(char_attckmun);
        //组合伤害数值
        MakeNumbers* nowattcknumber = new MakeNumbers(attcknum);
        //设置在怪物头上一半距离弹出伤害
        nowattcknumber->numbers->setPosition(ccp(monster->getContentSize().width/2,monster->getContentSize().height*1.5f));
        //设置动画赛贝尔曲线
        ccBezierConfig bezier;
        bezier.controlPoint_1=CCPointMake(50,monster->getContentSize().height*2.0f);
        bezier.controlPoint_2=CCPointMake(monster->getContentSize().width/2,monster->getContentSize().height);
        CCActionInterval* bezier_act = CCBezierTo::create(2.5f,bezier);
        //设置动画弹出放大和缩小
        CCActionInterval* scale_act = CCScaleTo::create(2.0f,1.5f);
        CCActionInterval* scale_actby = CCScaleBy::create(1.0f,2.0f);
        //设置动画淡出淡入(开始显示,最后隐藏)
        CCActionInterval* fade_actby = CCFadeIn::create(2.0f);
        CCActionInterval* fade_actby2 = CCFadeOut::create(2.0f);
        //最后执行移除回调函数,不消耗内存,用完就释放
        CCFiniteTimeAction *actbackfun = CCCallFuncO::create(monster, callfuncO_selector(SpiritsMonster::ShowNumberCallBack_setvisible),monster);
        nowattcknumber->numbers->runAction(CCSequence::create(scale_actby,scale_actby->reverse(),NULL));
        nowattcknumber->numbers->runAction(fade_actby2);
        for (int i = 0; i < numberstr->length(); i++)
        {
            CCActionInterval* fade_actby_back = fade_actby->reverse();
            nowattcknumber->numbers->getChildByTag(10+i)->runAction(fade_actby_back);    
        }
        nowattcknumber->numbers->runAction(CCSequence::create(bezier_act,actbackfun,NULL));
        //添加到怪物Body中
        monster->addChild(nowattcknumber->numbers,10,12);
    }
}

 

http://www.cnblogs.com/zisou/p/cocos2d-x-demo1.html

posted @ 2017-06-26 14:12  lianhuaren  阅读(203)  评论(0编辑  收藏  举报