issue for removing item from mouse

A

Aleandroct

Guest
Hi everyone,
i'm a newbie in gml and following this guide on youtube i've created a inventory interactive (like the guide).
Now all ok ,but when i pick-up the object in the inventory and put in some object, i solve for the disappar in the inventory but not in the mouse drag drop. I tried with place_meeting in the object but nothing or in obj mouseitem

how to destroy the object in the mouse when i used the item selected with some object?

thank you in advance
 
A

Aleandroct

Guest
this is in obj_inventory
Create Event:
execute code:

/*
Items
0 = sword
1 = red potion
2 = blue potion
3 = key
*/

globalvar showInv; //mostrare l'inventario?
showInv = true; //sì

globalvar maxItems; //max item -.-
maxItems = 16;
stack = 0;
for (i = 0; i < maxItems; i += 1){
global.inventory = -1;
button = instance_create(0,0,obj_invbutton);
button.slot = i;
}
globalvar mouseItem;
mouseItem = -1;
instance_create(0,0,obj_mouseitem);
instance_create(512,352,obj_try);

globalvar fullInv;
fullInv = 0;
globalvar noitem;
noitem = 0;

scr_itemAdd (0);


Draw Event:
execute code:

if (showInv){
var width,height;
width = 164;
height = 172;
draw_set_color(c_black);
draw_set_alpha(0.8);
draw_rectangle(0,0,width,height,0);
draw_set_alpha(1);


for(i = 0; i < maxItems; i += 1){
stack = 0
k = 0
if i >= maxItems*.25 then stack = 40
if stack > 0 then k = 40*(.25*maxItems)
if i >= maxItems*.5 then stack = 40*2
if stack > 40 then k = 40*(.25*maxItems)*2
if i >= maxItems*.75 then stack = 40*3
if stack > 40*2 then k = 40*(.25*maxItems)*3
draw_sprite(spr_border,0,24+(i*40)-k,32+stack)
button.x = 24+(i*40)-k
button.y = 32+stack
}
}
if fullInv = 1{
draw_set_halign(fa_left)
draw_set_color(c_black)
draw_text(32,96,"Inventory is full. :(")
}
if noitem = 1{
draw_set_halign(fa_left)
draw_set_color(c_black)
draw_text(32,96,"You don't have a sword :(")
}

this is in obj_invbutton
Draw Event:
execute code:

var item = global.inventory[slot];
var click = mouse_check_button_pressed(mb_left);

if (abs(mouse_x - x) < 16) && (abs(mouse_y - y) < 16){
draw_set_color(c_white);
draw_set_alpha(.5);
draw_rectangle(x-16,y-16,x+16,y+16,0);
draw_set_alpha(1);
if (click) {
if (item != -1){
scr_itemDrop_slot(slot);
instance_create (x,y,obj_evi);
}
if (mouseItem != -1){
scr_itemAdd_slot(mouseItem,slot);
}
mouseItem = item;
}
}
if (item != -1){
draw_sprite(spr_items,item,x,y);
}

and this is in obj_mouseitem
Draw Event:
execute code:

var item = mouseItem;
if (item != -1){
x = mouse_x;
y = mouse_y;
draw_sprite(spr_items,item,x,y,);
}


can you help me? Anywhere thank you for your time :D
 
Top