Jump to content

[SOLVED] Event drop items from inventory to the game environment


photo

Recommended Posts

Sorry for the stupid question, please give me some advice. I need to simulate the situation of dropping items from inventory to the game environment. By what event can we define this action? thanks in advance

Link to comment
  • 4 weeks later...

Thank you very much. We've implemented the object drag'n'drop from cell to cell. We've an issue with the drag'n'drop of unused items from the inventory to the ground. Now we're using a silly workaround:

int checkFocusGui() {
	Widget wd;
	int mX = engine.app.getMouseX();
	int mY = engine.app.getMouseY();
	for (int i=0; i<engine.gui.getNumChilds(); i++ ) {
		wd = engine.gui.getChild(i);
		if (wd.isHidden() == 1) continue;
		if (wd.getScreenPositionX()<mX && mX<(wd.getScreenPositionX()+wd.getWidth()) && wd.getScreenPositionY()<mY && mY<(wd.getScreenPositionY()+wd.getHeight())) return i;
	}
	return -1;
}

though this function is cumbersome, it has helped to solve many other problems in the game, such as scrolling lists, hot keys, etc. I use this method so far.

 

Thanks =)

Link to comment
×
×
  • Create New...