// 这里是我定义的一个结构
typedef struct tagActionDefItem
{
char ItemName;// 动作名称 用于传入的字符串 搜索
ACTIONIMGIDX ActionAray;
ROLETYPE RoleType;
}ActionDefItem;
// 这里定义一个量保存结构指针
std::vector<ActionDefItem*> m_actionLst;
// 这里加载配置
bool ActionDef::init() {
/// 加载文件初始化
FileUtils *util = FileUtils::getInstance();
if (util) {
std::string fullPath = util->fullPathForFilename("actordef.plist");
bool isExist = util->isFileExist(fullPath);
if (isExist) {
//ValueVector readArray = util->getValueVectorFromFile(fullPath);
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath);
ValueMap& framesDict = dict"def"].asValueMap();
for (auto iter = framesDict.begin(); iter != framesDict.end(); ++iter)
{
ValueMap& frameDict = iter->second.asValueMap();
std::string name = iter->first; // 名称
std::string tem = "";
tem = frameDict"move"].asString();
Vec2 movepos_(-1, -1);
if (tem.length() > 0) {
movepos_ = PointFromString(tem); // 移动 动作的图片 起始 结束 图片编号
}
tem = frameDict"attack"].asString();
Vec2 attackpos_(-1, -1);
if (tem.length() > 0) {
attackpos_ = PointFromString(tem); // 移动 动作的图片 起始 结束 图片编号
}
Vec2 deadpos_(-1, -1);
tem = frameDict"dead"].asString();
if (tem.length() > 0) {
deadpos_ = PointFromString(tem);
}
Vec2 addlifepos_(-1, -1);
tem = frameDict"addlife"].asString();
if (tem.length() > 0) {
addlifepos_ = PointFromString(tem);
}
Vec2 jumppos_(-1, -1);
tem = frameDict"jump"].asString();
if (tem.length() > 0) {
jumppos_ = PointFromString(tem);
}
Vec2 roletypepos_(-1, -1);
tem = frameDict"roleType"].asString();
if (tem.length() > 0) {
roletypepos_ = PointFromString(tem);
}
ActionDefItem *def = new ActionDefItem();
strcpy_s(def->ItemName, ACTIONNAMELEN, name.c_str());
def->ActionAray.StartIdx = movepos_.x;
def->ActionAray.EndIdx = movepos_.y;
def->ActionAray.StartIdx = attackpos_.x;
def->ActionAray.EndIdx = attackpos_.y;
def->ActionAray.StartIdx = addlifepos_.x;
def->ActionAray.EndIdx = addlifepos_.y;
def->ActionAray.StartIdx = jumppos_.x;
def->ActionAray.EndIdx = jumppos_.y;
def->ActionAray.StartIdx = deadpos_.x;
def->ActionAray.EndIdx = deadpos_.y;
def->RoleType = ROLETYPE(int(roletypepos_.x));
//log("=================================");
log("struct itemname = %s", def->ItemName);// ===> 这里输出第次加载的内容
//log("ACTION_MOVE start = %d endidx = %d", def->ActionAray.StartIdx, def->ActionAray.EndIdx);
//log("ACTION_ATTACK start = %d endidx = %d", def->ActionAray.StartIdx, def->ActionAray.EndIdx);
//log("ACTION_ADDLIFE start = %d endidx = %d", def->ActionAray.StartIdx, def->ActionAray.EndIdx);
//log("ACTION_JUMP start = %d endidx = %d", def->ActionAray.StartIdx, def->ActionAray.EndIdx);
//log("ACTION_DEAD start = %d endidx = %d", def->ActionAray.StartIdx, def->ActionAray.EndIdx);
//log("RoleType = %d", def->RoleType);
m_actionLst.push_back(def);
}
}
}
std::vector<ActionDefItem *>::iterator it;
for (it = m_actionLst.begin(); it != m_actionLst.end(); it++)
{
log("for ======> itemname = %s", (*it)->ItemName);
}
m_isOk = true;
return true;
}
// 这里是实时的输出日志
struct itemname = boss_09
struct itemname = boss_01
struct itemname = boss_02
struct itemname = boss_03
struct itemname = boss_04
struct itemname = boss_05
struct itemname = boss_06
struct itemname = boss_07
struct itemname = boss_08
struct itemname = boss_10
struct itemname = boss_11
struct itemname = boss_12
struct itemname = boss_13
struct itemname = bullet_boss_08
struct itemname = boss_14
struct itemname = bullet_boss_09
struct itemname = boss_15
struct itemname = evil_20
struct itemname = boss_16
struct itemname = evil_21
struct itemname = boss_17
struct itemname = bullet_boss_04
struct itemname = boss_21
struct itemname = boss_18
struct itemname = bullet_boss_05
struct itemname = boss_20
struct itemname = boss_19
struct itemname = bullet_boss_07
struct itemname = boss_22
struct itemname = bullet_boss_06
struct itemname = boss_23
struct itemname = bullet_boss_01
struct itemname = boss_24
struct itemname = boss_25
struct itemname = bullet_boss_03
struct itemname = boss_26
struct itemname = evil_01
struct itemname = other_03
struct itemname = evil_02
struct itemname = other_01
struct itemname = evil_03
struct itemname = evil_04
struct itemname = evil_05
struct itemname = evil_06
struct itemname = evil_07
struct itemname = evil_08
struct itemname = evil_09
struct itemname = evil_10
struct itemname = evil_11
struct itemname = evil_12
struct itemname = evil_13
struct itemname = evil_14
struct itemname = evil_15
struct itemname = evil_16
struct itemname = evil_17
struct itemname = evil_18
struct itemname = evil_19
struct itemname = hero_01
struct itemname = hero_02
struct itemname = hero_03
struct itemname = bullet_boss_02
struct itemname = bullet_hero_02
struct itemname = bullet_boss_10
struct itemname = bullet_hero_01
struct itemname = bullet_hero_03
struct itemname = other_02
// 这里是加载完后输出的日志
for ======> itemname = boss_09
for ======> itemname = boss_01
for ======> itemname =
for ======> itemname =
for ======> itemname = boss_04
for ======> itemname = boss_17
for ======> itemname =
for ======> itemname =
for ======> itemname = boss_16
for ======> itemname = boss_17
for ======> itemname = boss_16
for ======> itemname = boss_16
for ======> itemname = boss_16
for ======> itemname = boss_16
for ======> itemname = boss_16
for ======> itemname = bullet_boss_09
for ======> itemname = boss_17
for ======> itemname = boss_16
for ======> itemname = boss_16
for ======> itemname = evil_21
for ======> itemname = boss_17
for ======> itemname = bullet_boss_04
for ======> itemname =
for ======> itemname =
for ======> itemname = bullet_boss_05
for ======> itemname = evil_18
for ======> itemname =
for ======> itemname =
for ======> itemname = evil_06
for ======> itemname = evil_18
for ======> itemname = evil_06
for ======> itemname = evil_06
for ======> itemname = evil_06
for ======> itemname = other_02
for ======> itemname = bullet_boss_03
for ======> itemname = boss_26
for ======> itemname = evil_01
for ======> itemname = ???r_03
for ======> itemname = evil_02
for ======> itemname = bullet_hero_02
for ======> itemname = evil_18
for ======> itemname = other_02
for ======> itemname = evil_06
for ======> itemname = evil_06
for ======> itemname = bullet_boss_10
for ======> itemname = evil_08
for ======> itemname = bullet_hero_02
for ======> itemname = evil_10
for ======> itemname = evil_11
for ======> itemname = evil_12
for ======> itemname =
for ======> itemname =
for ======> itemname = evil_15
for ======> itemname = evil_16
for ======> itemname = evil_17
for ======> itemname = evil_18
for ======> itemname = bullet_boss_10
for ======> itemname = bullet_boss_10
for ======> itemname = bullet_boss_10
for ======> itemname = bullet_hero_03
for ======> itemname = bullet_boss_02
for ======> itemname = bullet_hero_02
for ======> itemname = bullet_boss_10
for ======> itemname = bullet_hero_03
for ======> itemname = bullet_hero_03
for ======> itemname = other_02
为什么加载时输出没有问题,加载完成后再输出就成这样的了呢,请帮我看下,谢谢