Size of object

Started by Babar, Fri 10/02/2006 00:14:56

Previous topic - Next topic

Babar

Is there any way to check the height and width of an object? Or even the height and width of a sprite? Objects in my Room can be manipulated and moved by the player within a certain box. I'd like to be able to set limits. Right now I'm using an x and y limit I set on my own, but I'd prefer to have each object checked individually and the limit set according to it's size. Help would be most appreciated.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

strazer

Yes, you can use the GetGameParameter function to get an Object.Graphic's width and height.

Babar

Haha! Wonderful. I wish I'd known about this before. Could have helped with other stuff. Part of the problem was that I didn't know what to search for.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Babar

#3
Ok, there is a new problem. Or rather, a spin on the old one:

I realised that the object graphic's width is not really relevant. See, when the player has control of the object, it is actually an inventory item that is being controlled. Clicking on the object makes it's visible=false, and then turns the active inventory into an inventory item that has the same sprite as the object. So it's actually the mouse coordinates that matter.

The problem now is the eUseInv mode's hotspot. It can be anywhere, depending on the nature of the inventory item. It is necessary for me to know where it is so that I can control the limits of where the object can be placed. Otherwise the object can be placed outside the box, or too far inside.

I can't see any way to find the mouse modes hotspot. there is Mouse.mode(blah).ChangeModeHotspot(), but that only changes it, not reads it. I realise I can use properties, but is there some other general way to do it?

EDIT: While on the topic of GetGameParameter, can someone please tell my why using:
while (i<=GetGameParameter(GP_GP_NUMINVITEMS ,0,0,0){

instead of:
while (i<=4){

results in "Error: Character.InventoryQuantity: invalid inventory index"

when the both should be the same? (My game currently has 4 inventory items)
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

monkey0506

Well...for one thing it's GP_NUMINVITEMS not GP_GP_NUMINVITEMS... :P

The reason would probably be this:

Quote from: The ManualGP_NUMINVITEMS - Returns the number of inventory items in the game plus 1

So it's giving you an invalid index because it is the number of items plus 1.  Unless you take the online manual entry (here) at its word, because it leaves the last bit about adding one off (this needs to be fixed (Chris?)).

Just use "while (i < GetGameParameter(GP_NUMINVITEMS, 0, 0, 0)" instead of <=.

Babar

But...but... my manual doesn't say that! It works now, thanks. Any idea about the other problem?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

monkey0506

Well apparently it's been added (corrected) somewhere along the lines of 2.72.  As for getting the hotspot coordinates, I have no idea.  Perhaps you could suggest the functions Mouse.GetHotspotX(CursorMode) and Mouse.GetHotspotY(CursorMode) as they don't seem to exist, but you might want to check the tracker first.

As a work around, could you just set up two global integers and update them at the same time (every time) that the cursor hotspot is changed?

[EDIT:]

I went ahead and look at the tracker, but I didn't find anything for those functions.  So...go suggest it in the Tech Forum!

SMF spam blocked by CleanTalk