选择广告资源项

时间:2016-06-02 22:52:07

标签: inventory game-maker gml

/// 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'我不确定它是否实际引用了该对象,或者它是否只是一个随机数。文档并没有真正解释得很好,用“自我”和“自我”来尝试。但是返回-1会导致它拖动每个项目。

1 个答案:

答案 0 :(得分:1)

您可以使用instance_position(x,y,oInventoryBox);来确定选择了哪个项目 我没有对其进行测试,但是当与id结合使用时,它应返回所点击项目的mouse_check_button_pressed(mb_left);

if(mouse_check_button_pressed(mb_left))
{
    if(position_meeting(mouse_x,mouse_y,obj))
    {
        global.clicked = instance_position(mouse_x,mouse_y,obj);
    }
}

if(mouse_check_button_released(mb_left))
{
    global.clicked = 0;
}

if(global.clicked = id) // You can replace this with your inventory grid handler.
{
    x = (mouse_x div 32) * 32;
    y = (mouse_y div 32) * 32;
}
相关问题