本文整理汇总了C++中CSprite::setImage方法的典型用法代码示例。如果您正苦于以下问题:C++ CSprite::setImage方法的具体用法?C++ CSprite::setImage怎么用?C++ CSprite::setImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSprite
的用法示例。
在下文中一共展示了CSprite::setImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddAtoms
void CInventory::AddAtoms(char* i_strAtomSymbol, int i_nCount)
{
bool bMatchFound = false;
int matchIndex = -1;
if (inventoryCount == 0)
{
// HASAN - debug
//s3eDebugOutputString("Adding inventory sprite to sprite manager.");
// add the inventory to the sprite manager when the first atom is added
g_Game.getSpriteManager()->addSprite(inventory_sprite);
}
if (inventoryCount > 0)
{
for (int i = 0; i < MAX_COUNT; i++)
{
if (!strcmp(atoms[i], i_strAtomSymbol))
{
bMatchFound = true;
matchIndex = i;
break;
}
}
}
if (!bMatchFound)
{
// match
strcpy(atoms[inventoryCount], i_strAtomSymbol);
atomCount[inventoryCount] += i_nCount;
CAtom* atom = new CAtom();
atom->Init(i_strAtomSymbol);
// horizontal center, same as inventory graphic
int posX = (Iw2DGetSurfaceWidth() / 2) - (IMAGE_SIZE_WIDTH / 2);
int posY = Iw2DGetSurfaceHeight() - (IMAGE_SIZE_HEIGHT / 2);
// offset inventory horizontally to fit in the container
posX = posX + (10 + (64 / 2)); // NOTE: 64 = atom size, 10 = border + spacing
if (inventoryCount > 0)
{
posX = posX + (inventoryCount * (64 + 15)); // NOTE: 64 = atom size, 15 = spacing + border + spacing
}
atom->setPosAngScale(posX, posY, 0, IW_GEOM_ONE);
atom->setVelocity(0,0);
// HASAN - new to create/show the inventory count images
CIw2DImage* inventoryCountImage = Iw2DCreateImageResource("inventory_number");
CSprite* inventoryCountSprite = new CSprite();
inventoryCountSprite->setImage(inventoryCountImage, "inventory_number");
// NOTE: image width & height = 25 & font width & height = 30
inventoryCountSprite->setPosition(posX + 13 + (30 / 2), posY + (30 / 2) + 3);
inventoryCountSprite->setDestSize(30, 30); // make larger than source to fit behind the text properly
g_Game.getSpriteManager()->addSprite(inventoryCountSprite);
atomCountImages[inventoryCount] = inventoryCountSprite;
atomObjs[inventoryCount] = atom;
inventoryCount++;
}
else
{
atomCount[matchIndex] += i_nCount;
}
}