本文整理汇总了C++中InventoryItem::item方法的典型用法代码示例。如果您正苦于以下问题:C++ InventoryItem::item方法的具体用法?C++ InventoryItem::item怎么用?C++ InventoryItem::item使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryItem
的用法示例。
在下文中一共展示了InventoryItem::item方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onArmorDragStop
void InventoryItem::onArmorDragStop(Event::Mouse* event)
{
// Check if mouse is over this item
if (!Rect::inRect(event->position(), position(), size()))
{
return;
}
if (ItemsList* itemsList = dynamic_cast<ItemsList*>(event->target()))
{
InventoryItem* draggedItem = itemsList->draggedItem();
auto itemObject = draggedItem->item();
if(itemObject->subtype() != Game::ItemObject::Subtype::ARMOR) return;
itemsList->removeItem(draggedItem, 1);
// place current armor back to inventory
if (_item)
{
itemsList->addItem(this, 1);
}
this->setItem(itemObject);
if (auto armor = dynamic_cast<Game::ArmorItemObject*>(itemObject))
{
Game::getInstance()->player()->setArmorSlot(armor);
}
}
}
示例2: onHandDragStop
void InventoryItem::onHandDragStop(Event::Mouse* event, HAND hand)
{
// Check if mouse is over this item
if (!Rect::inRect(event->position(), position(), size()))
{
return;
}
if (ItemsList* itemsList = dynamic_cast<ItemsList*>(event->target()))
{
InventoryItem* itemUi = itemsList->draggedItem();
auto item = itemUi->item();
itemsList->removeItem(itemUi, 1);
// place current weapon back to inventory
if (_item)
{
itemsList->addItem(this, 1);
}
this->setItem(item);
auto player = Game::getInstance()->player();
if (hand == HAND::LEFT)
{
player->setLeftHandSlot(item);
}
else
{
player->setRightHandSlot(item);
}
}
}