【发布时间】:2016-06-02 22:52:07
【问题描述】:
/// Drag Icon
visible = oInventoryBox.visible;
if(position_meeting(mouse_x,mouse_y,oInventoryIconParent)){
if(mouse_check_button_pressed(mb_left)){ // grab the item //
global.heldIcon = id;
}
}
if(global.heldIcon == id){
box = instance_nearest(mouse_x,mouse_y,oInventoryBox);
if(mouse_check_button(mb_left)){ // drag the item //
x = mouse_x;
y = mouse_y;
}
if(mouse_check_button_released(mb_left)){ // release the item //
if(instance_exists(box)){
global.boxes[boxNumber].item = box.item; // give the old box the new boxes item
global.boxes[boxNumber].item.boxNumber = boxNumber;// give the new boxes item it's new box number
box.item = id; // put the item in the new box
boxNumber = box.boxID; // give this item it's new box number
}
box = -1; // reset box and the item being dragged.
global.heldIcon = -1;
}
}
http://webmshare.com/WNdZd 好吧,所以我的库存被破坏了。正如您在视频中看到的那样,它似乎只抓住了这一颗种子,而忽略了其他一切。如果有人看到什么问题,那将是美丽。
还有当我在视频中出现抓取不同种子时,实际上只是我双击切换原始种子的位置。
我认为问题出在“id”上,我不确定它是否实际引用了该对象,或者它只是一些随机数。文档并没有很好地解释它,用 'self' 尝试过,但返回 -1 导致它拖动每个项目。
【问题讨论】:
标签: inventory game-maker gml