本文整理汇总了C++中BaseSprite::loadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseSprite::loadFile方法的具体用法?C++ BaseSprite::loadFile怎么用?C++ BaseSprite::loadFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseSprite
的用法示例。
在下文中一共展示了BaseSprite::loadFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSprite
bool AdEntity::setSprite(const char *filename) {
if (_currentSprite == _sprite) {
_currentSprite = nullptr;
}
delete _sprite;
_sprite = nullptr;
BaseSprite *spr = new BaseSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
delete _sprite;
_sprite = nullptr;
return STATUS_FAILED;
} else {
_sprite = spr;
_currentSprite = _sprite;
return STATUS_OK;
}
}
示例2: scCallMethod
//////////////////////////////////////////////////////////////////////////
// high level scripting interface
//////////////////////////////////////////////////////////////////////////
bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) {
//////////////////////////////////////////////////////////////////////////
// SetSprite
//////////////////////////////////////////////////////////////////////////
if (strcmp(name, "SetSprite") == 0) {
stack->correctParams(1);
ScValue *val = stack->pop();
bool setCurrent = false;
if (_currentSprite && _currentSprite == _sprite) {
setCurrent = true;
}
delete _sprite;
_sprite = nullptr;
if (val->isNULL()) {
_sprite = nullptr;
if (setCurrent) {
_currentSprite = nullptr;
}
stack->pushBool(true);
} else {
const char *filename = val->getString();
BaseSprite *spr = new BaseSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
script->runtimeError("SetSprite method failed for file '%s'", filename);
stack->pushBool(false);
} else {
_sprite = spr;
if (setCurrent) {
_currentSprite = _sprite;
}
stack->pushBool(true);
}
}
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetSprite") == 0) {
stack->correctParams(0);
if (!_sprite || !_sprite->getFilename()) {
stack->pushNULL();
} else {
stack->pushString(_sprite->getFilename());
}
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// GetSpriteObject
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "GetSpriteObject") == 0) {
stack->correctParams(0);
if (!_sprite) {
stack->pushNULL();
} else {
stack->pushNative(_sprite, true);
}
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// AddTalkSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "AddTalkSprite") == 0) {
stack->correctParams(2);
const char *filename = stack->pop()->getString();
bool ex = stack->pop()->getBool();
BaseSprite *spr = new BaseSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile(filename))) {
stack->pushBool(false);
script->runtimeError("AddTalkSprite method failed for file '%s'", filename);
} else {
if (ex) {
_talkSpritesEx.add(spr);
} else {
_talkSprites.add(spr);
}
stack->pushBool(true);
}
return STATUS_OK;
}
//////////////////////////////////////////////////////////////////////////
// RemoveTalkSprite
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "RemoveTalkSprite") == 0) {
stack->correctParams(2);
//.........这里部分代码省略.........
示例3: loadBuffer
TOKEN_DEF_END
//////////////////////////////////////////////////////////////////////////
bool AdEntity::loadBuffer(byte *buffer, bool complete) {
TOKEN_TABLE_START(commands)
TOKEN_TABLE(ENTITY)
TOKEN_TABLE(SPRITE)
TOKEN_TABLE(X)
TOKEN_TABLE(Y)
TOKEN_TABLE(TEMPLATE)
TOKEN_TABLE(NAME)
TOKEN_TABLE(SCALABLE)
TOKEN_TABLE(REGISTRABLE)
TOKEN_TABLE(INTERACTIVE)
TOKEN_TABLE(SHADOWABLE)
TOKEN_TABLE(COLORABLE)
TOKEN_TABLE(ACTIVE)
TOKEN_TABLE(EVENTS)
TOKEN_TABLE(FONT)
TOKEN_TABLE(TALK_SPECIAL)
TOKEN_TABLE(TALK)
TOKEN_TABLE(CURSOR)
TOKEN_TABLE(REGION)
TOKEN_TABLE(BLOCKED_REGION)
TOKEN_TABLE(EDITOR_SELECTED)
TOKEN_TABLE(SCRIPT)
TOKEN_TABLE(SOUND_START_TIME)
TOKEN_TABLE(SOUND_VOLUME)
TOKEN_TABLE(SOUND_PANNING)
TOKEN_TABLE(SOUND)
TOKEN_TABLE(SUBTYPE)
TOKEN_TABLE(CAPTION)
TOKEN_TABLE(PROPERTY)
TOKEN_TABLE(WAYPOINTS)
TOKEN_TABLE(IGNORE_ITEMS)
TOKEN_TABLE(ROTABLE)
TOKEN_TABLE(ROTATABLE)
TOKEN_TABLE(ALPHA_COLOR)
TOKEN_TABLE(SCALE)
TOKEN_TABLE(RELATIVE_SCALE)
TOKEN_TABLE(ALPHA)
TOKEN_TABLE(EDITOR_PROPERTY)
TOKEN_TABLE(ITEM)
TOKEN_TABLE(WALK_TO_X)
TOKEN_TABLE(WALK_TO_Y)
TOKEN_TABLE(WALK_TO_DIR)
TOKEN_TABLE(SAVE_STATE)
TOKEN_TABLE_END
byte *params;
int cmd;
BaseParser parser;
if (complete) {
if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_ENTITY) {
_gameRef->LOG(0, "'ENTITY' keyword expected.");
return STATUS_FAILED;
}
buffer = params;
}
AdGame *adGame = (AdGame *)_gameRef;
BaseSprite *spr = nullptr;
int ar = 0, ag = 0, ab = 0, alpha = 0;
while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) {
switch (cmd) {
case TOKEN_TEMPLATE:
if (DID_FAIL(loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
}
break;
case TOKEN_X:
parser.scanStr((char *)params, "%d", &_posX);
break;
case TOKEN_Y:
parser.scanStr((char *)params, "%d", &_posY);
break;
case TOKEN_SPRITE: {
delete _sprite;
_sprite = nullptr;
spr = new BaseSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile((char *)params))) {
cmd = PARSERR_GENERIC;
} else {
_sprite = spr;
}
}
break;
case TOKEN_TALK: {
spr = new BaseSprite(_gameRef, this);
if (!spr || DID_FAIL(spr->loadFile((char *)params, adGame->_texTalkLifeTime))) {
cmd = PARSERR_GENERIC;
} else {
_talkSprites.add(spr);
}
}
break;
//.........这里部分代码省略.........