SpiritsPlayer::SpiritsPlayer(MainRoledata roledata,int zOrder,bool zhujiaoflag) { //先初始化部分数据 thisroledata = roledata; act_moveto_zi =NULL; act_moveto_npc =NULL; act_moveto_yinzi =NULL; actall=NULL; thiszhujiao_flag = zhujiaoflag; p_ui_name = new PublicShowUI(); flag = 0; npc = SpiritsPlayer::create(roledata.spiritUrl->getCString()); if(npc==NULL) { CCLog("图层路径有误,请检查路径"); return; } //设置NPC初始位置坐标(该坐标取决于当前画层) npc->setPosition(roledata.nowpoint); //NPC动画设置 playdonghua = SpiritsPlayer::updateNowAnt(roledata); npc->runAction(playdonghua); /**开始添加角色各部件**/ //添加角色名称 CCLabelTTF* label = CCLabelTTF::create(roledata.spiritname->getCString(), "微软雅黑",12); label->setColor(ccWHITE); label->setDirty(true); label->setPosition(ccp(npc->getContentSize().width/2,npc->getContentSize().height+6)); CCLabelTTF* labelback = CCLabelTTF::create(roledata.spiritname->getCString(), "微软雅黑",12); labelback->setColor(ccBLACK); labelback->setDirty(true); labelback->setPosition(ccp(npc->getContentSize().width/2+1,npc->getContentSize().height+6-1)); //添加NPC人物脚下阴影 yinzi = CCSprite::create(p_yinzi); if(yinzi==NULL) { CCLog("图层路径有误,请检查路径"); return; } if(zhujiaoflag==true) { yinzi->setPosition(ccp(npc->getContentSize().width/2,12)); } else { yinzi->setPosition(ccp(npc->getContentSize().width/2,5)); } //MakeNumbers* makenumber = new MakeNumbers(149); // //npc->addChild(makenumber->numbers,9,113); npc->addChild(yinzi,-1,110); npc->addChild(label,2,111); npc->addChild(labelback,1,112); }