Animating Objects Problems

Started by ozzie dave, Wed 20/07/2005 22:00:57

Previous topic - Next topic

ozzie dave

Hi Chris,

I am asking you this question out of shear frustration, please can you help me as I am having problems getting Object Animation to work in AGS 2.7.

On Scummbuddys suggestion I downloaded DEMOQUEST1 and looked at the Room Code for an animated object but on trying to copy still could not understand a small portion of code
can you please help me as follows:

ROOM 13:Broken Kerb Street

OBJECT: DOOR



function OperateMagicDoor() {

//

// This function checks to see if the player has the key to the door.

// If so theÃ,  doorÃ,  opens to reveal what's on the other side, and as

// Beman says it's wonderful. This door is programable via the handy

// Ags terminal disguised as a harmless ATM machine.Ã, 

//-------------------------------------------------------------------

Ã,  Ã, // Walk to the door

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  player.Walk (237,87,eBlock);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 



Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Operate the door

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  if (MagicDoorState==LOCKED) {

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // If the player has the key, open the door

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  if (player.InventoryQuantity[iKey.ID]>0) {

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  oInsidedoor.Graphic = AgsTerm[AgsTermId[0]].DoorSpr;

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  RestoreWalkableArea(3);

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  player.LoseInventory(iKey);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, 

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  player.Walk(237,87,eBlock);

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  PlaySound(sndDoorLock01);

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Wait(1);

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  PlaySound(sndDoorOpen01);

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  oDoor.SetView(24,0);Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Setup object for animation

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  oDoor.Animate(0,6,eOnce,eBlock,eForwards);// and then run the animation

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  DisplayMessage(13);

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  MagicDoorState = OPENED;

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  }

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  // Otherwise just tell him that he needs a key

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  else {

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Display("It's locked! You'll need a key to open it.");

Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  }



THE PROBLEM I AM HAVING IS IN THESE TWO CALLS:



oDoor.SetView(24,0);Ã, 

oDoor.Animate(0,6,eOnce,eBlock,eForwards)



IN THE AGS EDITOR VIEW SECTION I UNDERSTAND THAT IT IS VIEW 24 LOOP 0 â€" SO I BELIEVE I HAVE THAT RIGHT.



BUT DOOR ANIMATE I DON'T UNDERSTAND IS THE 0 THE OBJECT NUMBER SHOWN IN THE OBJECT SECTION IN THE ROOM EDITOR AND IF SO WHERE DOES THE 6 COME FROM AS I CAN SEE NO REFERENCE TO 6 AT ALL IN THE BROKEN KERB STREET ROOM IN AGS OR THE VIEW SECTION.



Your help will be most appreciated as I cannot go forward untill I solve this issue.

Chris thank you for a great free software programme


Regards

Ozzie Dave


Ishmael



Scripting -> Object functions and properties -> Animate



Animate (object)

(Formerly known as AnimateObject, which is now obsolete)
(Formerly known as AnimateObjectEx, which is now obsolete)


Object.Animate(int loop, int delay, optional RepeatStyle,
Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã,  Ã, optional BlockingStyle, optional Direction)

Starts the object animating, using loop number LOOP of its current view. The overall speed of the animation is set with DELAY, where 0 is the fastest, and increasing numbers mean slower. The delay for each frame is worked out as DELAY + FRAME SPD, so the individual frame speeds are relative to this overall speed.
The RepeatStyle parameter sets whether the animation will continuously repeat the cycling through the frames. This can be eOnce (or zero), in which case the animation will start from the first frame of LOOP, and go through each frame in turn until the last frame, where it will stop. If RepeatStyle is eRepeat (or 1), then when the last frame is reached, it will go back to the first frame and start over again with the animation. If RepeatStyle is 2 then it will do the animation once, but then return the graphic to the first frame and stop (whereas repeat=0 will leave the graphic on the last frame).

For blocking you can pass either eBlock (in which case the function will wait for the animation to finish before returning), or eNoBlock (in which case the animation will start to play, but your script will continue). The default is eBlock.

direction specifies which way the animation plays. You can either pass eForwards (the default) or eBackwards.

You need to use SetView at some stage before this command, in order to set up the object's current view.

Example:

object[0].Animate(2, 5);
object[1].Animate(1, 3, eOnce, eBlock, eBackwards);

will animate object 0 using loop 2 of its current view, at speed 5, and play the animation once only. This happens in the background. Then, object 1 will animate backwards using loop 1 of its current view, at speed 3. The function won't return until the animation is finished.

See Also: Character.Animate, Object.Animating, Object.SetView, Object.StopAnimating



Your six in there is the animation delay. Now what is the problem exactly?
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

RickJ

Quote
oDoor.Animate(0,6,eOnce,eBlock,eForwards);// and then run the animation

oDoor is the script-o-name of the object which is actually a struct variable that represents the object.  So in this case you don't need to specify the object's id number.   

Also note that DemoQuest is a community effort and that CJ may or may not be familiar with ur specifics.

SMF spam blocked by CleanTalk