Moving two objects, lying upon each other [SOLVED]

Started by Dambuilder, Tue 09/08/2005 15:12:27

Previous topic - Next topic

Dambuilder

In my game, there is a cupboard with a flowerpot on it. You'll have to move the cupboard to the right, then the flowerpot falls off it and crashes.
Each is an individual object.

However, for any reason I can't make those two object move at the same time, not to mention make the pot fall down to the floor after the cupboard stops. It always gets stuck and after the cupboard has finished moving.

When I f.ex. insert a "while" command before the MovingObject line (followed by a Wait) the game freezes.

Another problem is that I can't have the flower pot to be on top of the cupboard. It always turns up behind it.  >:(

Please help, it's driving me nuts!  :P
Everybody else is having one, so why not me?

strazer

Quote from: strazer on Mon 04/04/2005 05:29:12
If object A's baseline is further down than the baseline of object/character B, object A is drawn in front of B.
By default, character and object baselines are at their coordinates, the bottom of the sprite.

So if object A is positioned below object B, A is drawn in front of B.
Now, if you want object A to be drawn behind object B, you can simply re-position the objects so object A's bottom is above object B's bottom or set a new baseline for object A ("Set baseline" button) and place it above object B's bottom or set a new baseline for object B and place it below object A's bottom. Or set a new baseline for both and make sure object A's new baseline is above object B's new baseline.

But keep in mind that the baselines also affect how characters are drawn. The same principle applies: If the character's baseline (also bottom by default) is below object A's baseline, he is drawn in front. If it's above object A's baseline, he is drawn behind it.
Just play around a bit and find out what works best for your situation.

As for the movement, try something like this (AGS v2.7):

Code: ags

// script for cupboard: Interact with object

  oFlowerpot.Move(oFlowerpot.X + 20, oFlowerpot.Y, 3, eNoBlock, eAnywhere); // start moving pot 20 pixels to the right and continue script
  oCupboard.Move(oCupboard.X + 20, oCupboard.Y, 3, eBlock, eAnywhere); // move cupboard 20 pixels to the right and wait

  oFlowerpot.Animate( ...whatever... ); // flowerpot falling and crashing


You have to tweak it with your object names and amount of pixels you want them to move, obviously.

Dambuilder

Everybody else is having one, so why not me?

SMF spam blocked by CleanTalk