My question's so simple today you'll scoff before you've finished reading it.
How do I write code that reflects...
"If the player has an active inventory, and the active inventory is iABC, and he left clicks while the cursor is over a non-transparent part of object oXYZ, then do something."
Thank you.
if (player.ActiveInventory == iABC && Object.GetAtScreenXY(mouse.x, mouse.y) == oXYZ)
NOTE: I dont know if pixel-perfect click detection is on in your game. Since you specifically mentioned "non transparent part", if it's actually off and you want it to be off for most of the game, then you will additionally need to do this around this test:
SetGameOption(PIXELPERFECT, 1);
... click test
SetGameOption(PIXELPERFECT, 0);
But can't this be implemented simply by using the object's "use inventory on" event? I don't see that this requires any special collision check.
A left click while the cursor's hotspot is over a non-transparent area of an object sounds exactly like standard AGS behavior.
Quote from: Khris on Sun 20/12/2020 13:55:16
But can't this be implemented simply by using the object's "use inventory on" event? I don't see that this requires any special collision check.
A left click while the cursor's hotspot is over a non-transparent area of an object sounds exactly like standard AGS behavior.
Yes, I guess I ignored the implication behind the question when making a post. This kind of click is registered if player has an active inventory and clicks exactly on object sprite, so long as "pixel-perfect" mode is on. So normally you would not need to check that yourself, but use standard event instead.
Could you clarify why did you ask this in the first place, what kind of problem are you trying to solve?