コード例 #1
0
ファイル: HeroEnety.cpp プロジェクト: zzljzb/MadGod
bool HeroEnety::init(HeroEunm _HeroEunm, RaceEunm _RaceEunm, int _roadid)
{
	mRaceEunm = _RaceEunm;
	mHeroEunm = _HeroEunm;
	mStateEunm = Stand;
	roadID = _roadid;
    mMentalEnum = Normal;
	std::string plistname ;
	std::string pngname ;
	std::string filename;
	switch (_HeroEunm)
	{
	case HeroEnety::ArrowMan:
		plistname = "";
		pngname = "";
		filename = "";
		break;
	case HeroEnety::SwordsMan:
		plistname = "HeroA.plist";
		pngname = "HeroA.png";
		filename = "walk_00.png";
		break;
	case HeroEnety::Missionary:
		plistname = "";
		pngname = "";
		break;
	default:
		break;
	}



	HeroManager::getInstance()->add(this);



	loadjson(1);
	mSprite = Sprite::create(filename);
	if (mRaceEunm == Blue) { mSprite->setFlipX(true); }
	this->addChild(mSprite);
	this->initAction(plistname, pngname);

	auto label = Label::create(String::createWithFormat("%d", NormalHP)->getCString() , "msyh.ttf",40);
	label->setPosition(Vec2(this->getPosition().x, this->getPosition().y+100));
	label->setColor(Color3B::WHITE);
	this->addChild(label);


	//this->scheduleUpdate();
	return true;
}
コード例 #2
0
ファイル: json.cpp プロジェクト: PowerKiller/code
/// "anims": { "#import" : { "file": "generics.json", "key": "animations", "replace": { "arg4" : "codefragment" }
/// "anims": { "#import" : { "file": "generics.json", "key": "animations", "replace": { "arg4" : { "#import": } }
/// "$moreanims": { "#import" : "generics.json" },
/// "anims": [ "anim1", "anim2", "anim3", "$moreanims"]
bool JSON_ResolveImport(JSON *g)
{
    JSON *j = g->getchild(IMPORTPHRASE);
    JSON *f = NULL;       // the exporting file: "generics.json"
    JSON *newg = NULL;    // the JSON which will replace the old section

    if(!j) return false;

    JSON *src = j->getchild("file");
    JSON *key = j->getchild("key");
    JSON *replace = j->getchild("replace");

    if(!src) { return false; }
    const char *srcname = src->valuestring;
    f = loadjson(srcname);

    if(!f) { return false; }

    if(key) {
        newg = f->getchild(key->valuestring);
    }
    else newg = f;

    if(!newg){ return false; }

    JSON_ResolveReplacements(newg, replace);

    // Replace g with newg:
    if(g->name) copystring(newg->name, g->name, strlen(g->name)); // "anims"
    newg->parent = g->parent;

    newg->next = g->next;
    newg->prev = g->prev;

    // tell the others
    if(g->next) g->next->prev = newg;
    if(g->parent->firstchild == g) g->parent->firstchild = newg;
    else g->prev->next = newg;

    newg->original = g;
    return true;
}