Two Quick Queries: click detection, closeable doors (solved)

Started by Sparky, Thu 28/09/2006 01:29:43

Previous topic - Next topic

Sparky

Hi folks! I've used the manual and forum searches to answer many other questions, but don't seem to know what terminology to use this time around.

Question 1) Overlapping object and hotspot
I have an animated object with a hotspot "within" it.  An example of this would be a bathtub and a rubber duck. I can't look at the rubber duck hotspot; the bathtub object intercepts the click. How can I look at the rubber duck "through" the bathtub?

Question 2) I have an interactive door that swings open and shut on "interact". When the door is open, the player can walk to it and go into a new room. I've got this working, but the way I'm doing this strikes me as both cumbersome and more than a little inelegant. I'm currently using RemoveWalkableArea() and RestoreWalkableArea() to allow access to the hall outside the door. When the player enters the hall, he steps on a region that  calls "ChangeRoom()". Is there a more efficient way to do this?                                                                   
Thanks for putting up with my temporary bout of newbie antics. I hope my questions are clearly stated.

Coolio

Question 1)
You'll need to make it so that the object is not clickable.
I think the code for it is:
Code: ags
object[your object].Clickable=false;


Replace "your object" with the object number or script name (if you've assigned one).
You would of course change "false" to "true" if you were making the object clickable again.
As for question 2 I'm not really sure if there is a better way to do what you want. I don't think there is, but someone else might know otherwise.
mmmmm... sparkly

Khris

I guess the bathtub object is supposed to be clickable, too.
Two ways: 1) Make the rubber duck a seperate object and make sure its baseline is below the bathtub's (otherwise the bathtub will be displayed in front of the ducky).
2) Make the area of the bathtub where the ducky is transparent and make sure "pixel-perfect click detection" is checked in the general settings pane. (You'll have to draw the duck on the background then, of course, if you didn't already.)

Concerning the door: You're already doing it the almost-best way, the only more elegant thing to do would be to make the door solid and adjust its blocking width and height.
(Look up Object.Solid and Object.BlockingWidth/Height in the manual.)
Thus you'll get a rectangle around the base of the object which the character can't pass through. You'll probably have to move the door object upon opening/closing, e.g.:
// open door
oDoor.Graphic=201;
oDoor.X=140;
// close door
oDoor.Graphic=200;
oDoor.X=170;

Sparky

Thank you both for your helpful replies.

Bathtub and duck: I've taken your advice and made the duck into an object. I adjusted the duck's mask so it wouldn't obscure parts of the bathtub (pixel perfect click detection is on). The duck's baseline is below the bathtub's baseline now, and it works perfectly. I can even animate both objects!

Door:
Object.Solid sounds very useful. This door is actually set in a diagonal wall, so the rectangular collision detection wouldn't really be appropriate here. But thank you anyway, I'm sure to end up using that technique in the near future!

SMF spam blocked by CleanTalk