本文整理汇总了C++中setSprite函数的典型用法代码示例。如果您正苦于以下问题:C++ setSprite函数的具体用法?C++ setSprite怎么用?C++ setSprite使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setSprite函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setSprite
void GameStart::showInstructions(bool show) {
LogManager &log_manager = LogManager::getInstance();
ResourceManager &resource_manager = ResourceManager::getInstance();
showInstruct = show;
if(!showInstruct) { // Hiding instructions
//Setup GameStart sprite
Sprite *p_temp_sprite = resource_manager.getSprite("gamestart");
if (!p_temp_sprite) {
log_manager.writeLog("GameStart::showInstructions(): Warning! Sprite 'gamestart' not found", "gamestart");
}
else {
log_manager.writeLog("GameStart::showInstructions(): Switching to start screen\n");
setSprite(p_temp_sprite);
setSpriteSlowdown(15);
}
} else { // Showing instructions
//Setup GameStart sprite
Sprite *p_temp_sprite = resource_manager.getSprite("instructions");
if (!p_temp_sprite) {
log_manager.writeLog("GameStart::showInstructions(): Warning! Sprite 'gamestart' not found", "instructions");
}
else {
log_manager.writeLog("GameStart::showInstructions(): Switching to instructions screen\n");
log_manager.writeLog("Frame: %s\n", p_temp_sprite->getFrame(0).getString().c_str());
setSprite(p_temp_sprite);
setSpriteSlowdown(0);
}
}
}
示例2: playSound
void SsScene3010DeadBoltButton::update() {
if (_countdown1 != 0 && (--_countdown1 == 0)) {
playSound(0);
setVisible(false);
setSprite(kScene3010DeadBoltButtonFileHashes1[_buttonIndex]);
}
if (_countdown2 != 0 && (--_countdown2 == 0)) {
setVisible(true);
setSprite(kScene3010DeadBoltButtonFileHashes2[_buttonIndex]);
}
}
示例3: setSprite
NixonPowerCell::NixonPowerCell(df::Position p) {
df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
df::LogManager &log_manager = df::LogManager::getInstance();
// Link to "largerock" sprite
df::Sprite *p_temp_sprite;
p_temp_sprite = resource_manager.getSprite("nixonpowercell");
if (!p_temp_sprite) {
log_manager.writeLog("NixonPowerCell::NixonPowerCell(): Warning! Sprite '%s' not found", "nixonpowercell");
}
else {
setSprite(p_temp_sprite);
setSpriteSlowdown(0);
}
setType("NixonPowerCell");
setSolidness(df::Solidness::HARD);
//Set starting position
setPosition(p);
health = 10;
hit_slowdown = 5;
hit_countdown = hit_slowdown;
was_hit = false;
has_flashed = false;
}
示例4: FixedObject
FixedSprite::FixedSprite(const sf::Vector2f& pos, const std::string& imagePath, bool addToFixedObjectList) : FixedObject(addToFixedObjectList)
{
//ctor
if (imagePath != "")
setSprite(imagePath);
setPosition(pos);
}
示例5: setSprite
Saucer::Saucer() {
df::LogManager &log_manager = df::LogManager::getInstance();
df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
df::WorldManager &world_manager = df::WorldManager::getInstance();
// Setup "saucer" sprite.
df::Sprite *p_temp_sprite = resource_manager.getSprite("saucer");
if (!p_temp_sprite) {
log_manager.writeLog("Saucer::Saucer(): Warning! Sprite '%s' not found",
"saucer");
} else {
setSprite(p_temp_sprite);
setSpriteSlowdown(4);
}
// Set object type.
setType("Saucer");
// Set speed in horizontal direction.
setXVelocity(-0.25); // 1 space left every 4 frames
// Move Saucer to start location.
moveToStart();
// Register interest in "nuke" event.
registerInterest(NUKE_EVENT);
Role &role = Role::getInstance();
if(role.isHost()) {
Role &role = Role::getInstance();
role.registerSyncObj(this);
}
}
示例6: getBlock
Entity Block::getBlock()
{
// set position
auto pos = new CPosition;
pos->setX(32);
pos->setY(32);
E.addComponent(std::type_index(typeid(CPosition)), pos);
// set sprite from a spritesheet
auto spr = new CSprite;
spr->setSize(32);
spr->setSprite(this->getSprite(0, 0)); // coordinates in spritesheet
E.addComponent(std::type_index(typeid(CSprite)), spr);
// set state (0 = moveable)
auto sta = new CState;
sta->setS(0);
E.addComponent(std::type_index(typeid(CState)), sta);
// set velocity
auto vel = new CVelocity;
vel->setVelX(32);
vel->setVelY(32);
E.addComponent(std::type_index(typeid(CVelocity)), vel);
return E;
}
示例7: setName
void Being::setSubtype(Uint16 subtype)
{
if (subtype == mSubType)
return;
mSubType = subtype;
if (getType() == MONSTER)
{
mInfo = MonsterDB::get(mSubType);
setName(mInfo->getName());
setupSpriteDisplay(mInfo->getDisplay());
}
else if (getType() == NPC)
{
mInfo = NPCDB::get(mSubType);
setupSpriteDisplay(mInfo->getDisplay(), false);
}
else if (getType() == PLAYER)
{
int id = -100 - subtype;
// Prevent showing errors when sprite doesn't exist
if (!itemDb->exists(id))
id = -100;
setSprite(Net::getCharHandler()->baseSprite(), id);
}
}
示例8: setSprite
Poder::Poder(const int t) {
tipo = t;
setSprite(RUTA_OBJETOS_GFX);
size.x = size.y = 32;
active = -1;
clock.restart();
}
示例9: setType
GameStart::GameStart(){
setType("GameStart");
//dragonfly managers needed for this
df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
//setup GameOversprite
df::Sprite *p_temp_sprite = resource_manager.getSprite("gamestart");
if (!p_temp_sprite){
df::LogManager &log_manager = df::LogManager::getInstance();
log_manager.writeLog("GameStart::GameStart(): Warning! Sprite '%s' not found", "gamestart");
}
else{
setSprite(p_temp_sprite);
setSpriteSlowdown(30);
setTransparency('#');
}
//put in center of window
setLocation(df::CENTER_CENTER);
//register interest
registerInterest(df::KEYBOARD_EVENT);
//play start music
p_music = df::ResourceManager::getInstance().getMusic("start music");
playMusic();
df::WorldManager &world_manager = df::WorldManager::getInstance();
world_manager.setBoundary(df::Box(df::Position(), 250, 250));
}
示例10: setType
StaticObject::StaticObject(int objType, sf::Vector2i position)
{
setType(objType);
setPosition(position);
setSprite();
setBounds();
}
示例11: registerInterest
Trap::Trap(int x, int y)
{
LogManager &log_manager = LogManager::getInstance();
#ifdef REGISTER
// Need to update fire rate control each step.
registerInterest(DF_STEP_EVENT);
#endif
// Set object type.
setType("Trap");
auto& resMgr = ResourceManager::getInstance();
setSprite(resMgr.getSprite("trap"));
setSpriteSlowdown(4);
setAltitude(1);
// Set starting location.
WorldManager &world_manager = WorldManager::getInstance();
Position pos(7, world_manager.getBoundary().getVertical() / 2);
setPosition(Position(x, y));
setBox(Box(Position(0, 0), getSprite()->getWidth(), getSprite()->getHeight()));
//setYVelocity(0.25);
// Set firing variables.
}
示例12: setSprite
_border::_border()
{
// Get instances of necessary managers.
LogManager &log_manager = LogManager::getInstance();
ResourceManager &resource_manager = ResourceManager::getInstance();
WorldManager &world_manager = WorldManager::getInstance();
// Set up border sprite.
Sprite *p_temp_sprite = resource_manager.getSprite("border");
if (!p_temp_sprite)
{
log_manager.writeLog("_border::_border(): Warning! Sprite '%s' not found", "border");
}
else
{
// If sprite is found, set sprite for this object.
setSprite(p_temp_sprite);
}
// Set type of border.
setType("_border");
// Make sure it collides with others so game objects don't pass through message box.
setSolidness(HARD);
setAltitude(2);
// Set position to middle center of the terminal.
Position pos(world_manager.getBoundary().getCorner().getX() + world_manager.getBoundary().getHorizontal()/2,
( world_manager.getBoundary().getCorner().getY() + world_manager.getBoundary().getVertical()/2) + 6);
setPosition(pos);
};
示例13: setType
Explosion::Explosion(df::Position *p){
setType(Type::EXPLOSION);
setSolidness(df::SPECTRAL);
df::LogManager &log_manager = df::LogManager::getInstance();
df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
df::Sprite *sprite;
sprite = resource_manager.getSprite("explosion");
if(!sprite){
log_manager.writeLog("Explosion::Explosion() could not load explosion sprite");
} else {
time_to_live = sprite->getFrameCount(); //set time as # of frames
log_manager.writeLog("Explosion::Explosion() frameCount %d", time_to_live);
setSprite(sprite);
}
if(p)
setPosition(*p);
registerInterest(df::STEP_EVENT);
if(Role::isServer()){
NetSyncing::create(this);
}
}
示例14: setSprite
MediumRock::MediumRock(df::Position p) {
df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
df::LogManager &log_manager = df::LogManager::getInstance();
// Link to "mediumrock" sprite
df::Sprite *p_temp_sprite;
p_temp_sprite = resource_manager.getSprite("mediumrock");
if (!p_temp_sprite) {
log_manager.writeLog("MediumRock::MediumRock(): Warning! Sprite '%s' not found", "mediumrock");
}
else {
setSprite(p_temp_sprite);
setSpriteSlowdown(0);
}
setType("MediumRock");
setSolidness(df::Solidness::SOFT);
//Set starting position
setPosition(p);
health = 15;
hit_slowdown = 5;
hit_countdown = hit_slowdown;
was_hit = false;
has_flashed = false;
}
示例15: setSprite
Mortar::Mortar(df::Position p, df::Object *new_player) {
df::ResourceManager &resource_manager = df::ResourceManager::getInstance();
df::LogManager &log_manager = df::LogManager::getInstance();
// Link to "mortar" sprite
df::Sprite *p_temp_sprite;
p_temp_sprite = resource_manager.getSprite("mortar");
if (!p_temp_sprite) {
log_manager.writeLog("Mortar::Mortar(): Warning! Sprite '%s' not found", "mortar");
}
else {
setSprite(p_temp_sprite);
setSpriteSlowdown(0);
}
setType("Mortar");
setSolidness(df::Solidness::SOFT);
//Set starting position
setPosition(p);
player = new_player;
fire_slowdown = 60;
fire_countdown = fire_slowdown;
firing_anim_slowdown = 5;
firing_anim_countdown = firing_anim_slowdown;
occupied = true;
firing = false;
}