hotspot on an object?

Started by spook1, Fri 04/11/2005 13:32:09

Previous topic - Next topic

spook1

Hi,

I'm back. After more than a year I found some time to continue my game based learning project.
And in doing so new questions arise :-)

Is there a way to create a hotspot on an object?

In my game I have a caterpillar vehicle driving along the road (like the slot machine bike game in the demo game).
When the right engine current is disconnected it turns left and vice versa.
To diconnect the current the player must cut a wire on board the moving vehicle.

Can I define a hotspot on the object?
is there a simple way to do so?

Extra complicated is that the vehicle chnges perspective (is shape) when turning, so calculating the hotspot-area is also a bit complicated.

Any suggestions?

regards,

Martijn

Elliott Hird

Why not make each bit that you can click an object, then move them in synch?

spook1

is that the only way to do it?

Ashen

You could possibly set a bounding box on the object, using the Object.X/Y properties:
Code: ags

//Interact with object
if (mouse.x > (oEngine.X + 5) && mouse.x < (oEngine.X + 10) && mouse.y > (oEngine.Y + 10) && mouse.y < (oEngine.Y + 20)) {
  // Do stuff
}

Keeping in mind (Object.X, Object.Y) is the bottom left corner of the object, and that you'd have to account for the difference between room coordinates (for objects) and screen coordinates (for the mouse) if you have a scrolling room.
Adding an extra check for the object graphic would mean you could set different 'hotspot' boxes for the different angles as the engine turns.

But yes, Elliott's way would be easier.
I know what you're thinking ... Don't think that.

SSH

You could use a GUI rather than an object: that way you could have a background with the "object" and a button for the hotspot...
12

strazer

If I understand you correctly, can't you just make the object non-clickable (oWire.Clickable property) and use a real hotspot on the engine?

SSH

I think that the thing is moving, strazer
12

spook1

Thanks for the vast amount of fast reactions.

Using the gui seems to be very elegant way, but can I use collision detection with a gui?

I think that moving objects in sync is the easiest way if I understand it correctly. If presumed that it is the same thing as creating a bounding box, but apparently it is not.

Is this a new feature to move objects in sync? What is it called??

Thanks again,
martijn

Ashen

No, it's not an in-built feature. (Well, unless it's been added in 2.71, but I doubt that.) You'd have to update the positions manually, in rep_ex.

You couldn't have collision detection with the GUI, but I think you'd still have the vehicle object (or is it a character, from your other post?) under it, that would have it. Again, unless I've missed the point.

And the difference between using the bounding box method and objects moving in sync, may be more to do with my misunderstanding the question to start with. Bounding boxes would probably be the most complicated way to do (which is why I thought of it, instead of using other objects, first), so just keep it as a last resort.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk