Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Sun 19/06/2005 20:40:48

Title: where do i set Object View to AnimateObject?
Post by: on Sun 19/06/2005 20:40:48
I keep getting the above error message when testing my gameÃ,  ???when I click on a small carousel I want to aniamte when the player touches it. If you can't use the graphic script editor to do it, how do I do it? Please help!

P.S. the carousel is view 4 with 3 frames of animation, and it is the only object in the room (object 0?).
Title: Re: where do i set Object View to AnimateObject?
Post by: Candle on Sun 19/06/2005 21:05:55
You can  put it in the
RunCharacterInteraction
RunCharacterInteraction (CHARID, int mode)

Processes the interaction list as if the player had clicked the mouse on character CHARID in cursor mode MODE. MODE is one of the MODE_* constants listed in the ProcessClick description.
Example:

RunCharacterInteraction(MAN,MODE_TALK);

will execute the code defined in the MAN'S "TALK TO CHARACTER" interaction.
See Also: ProcessClick, RunHotspotInteraction, RunInventoryInteraction


````````````````````````````

AnimateObject (int object, int loop, int delay, int repeat)

Starts the object number 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 REPEAT parameter sets whether the animation will continuously repeat the cycling through the frames. If REPEAT is zero, 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 REPEAT is 1, when the last frame is reached, it will go back to the first frame and start over again with the animation. If REPEAT is 2, 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).

Example:

AnimateObject(0,2,0,0);

will animate object 0 using loop 2 of its current view once.

Read the help file ;;

Animations
In most games you will use some sort of animation during the game, whether it be a flag waving in the breeze or the player bending over to pick something up. The term "animation" refers to the ability to change the look of, and move, objects.
Animations in AGS are managed using Views. A "view" is a set of one or more "loops". A loop is a set of frames which, when put together, give the effect of movement. Each frame in the view can be set a graphic and a speed. Go to the "Views" pane, under Visual Settings. This is the View Editor. Here you will see the main character's walking view.

Click the "New view" button to create us a new, empty view. Each loop is displayed horizontally with its number at the left hand side, frames going out to the right. To add a frame, click the grey "New frame" button. To delete a frame, right-click it.

To change a frame's graphic, double-left-click it. The sprite list screen will be displayed (you may remember this from the Object graphic selection) where you can choose the graphic you want to use for this frame.

Note that for walking animations, the first frame in each loop is reserved for the standing frame, and when walking it will only cycle through from the second frame onwards.

Below each frame you will see "SPD:0". This is the frame's relative speed, which you can change by clicking on the word "SPD:". The larger the number, the longer the frame stays (ie. the slower it is). When the animation is run, an overall animation speed will be set, so the actual speed of the frame will be: overall_speed + frame_speed . Note that you can use negative numbers for the frame speed to make it particularly fast, for example setting it to -3 means that the frame will stay for hardly any time at all.
Animation speed is specified in Game Loops (ie. animation speed 4 will show the frame for 4 game loops - at 40fps, that would be 0.1 seconds).

You will also see something marked "NO SND". If you click this, you can enter a sound number that will be played when this frame becomes visible on the screen. This is especially useful for footstep sounds.

You run an animation by using the interaction editor or text script animation commands, which will be explained in detail later.

To animate an object, you first of all need to set the object's view to the correct view number (use the SetObjectView script command), and then use the AnimateObject script command to actually start the animation.
Title: Re: where do i set Object View to AnimateObject?
Post by: Ashen on Sun 19/06/2005 23:37:15
You can either put it in one of the Player enters screen interactions (.. before fade-in, .. after fade-in, First time ..), or immediately before you run the animation, e.g.:

// Script for interact with object
SetObjectView (0, 4);
AnimateObject (0, 0, 3, 0);// Or whatever settings you want.


QuoteIf you can't use the graphic script editor to do it
You can - it's the Object - Set object view number interaction, so:

  Object - Set object view number (0, 4)
  Object - Start object animating (0,0,3,False)

Just remember (whether you use the interaction editor or scripting.) to call it before you start the animation.
Title: Re: where do i set Object View to AnimateObject?
Post by: on Mon 20/06/2005 05:40:18
Hey thanks guys!