Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: fovmester on Wed 05/10/2005 11:56:05

Title: How to use blink view?
Post by: fovmester on Wed 05/10/2005 11:56:05
How do you get the characters to blink when you've given them a blink view?
I stood beside one of my "blinking" characters and she never blinks!

What have I missed!? Doesn't it work sort of like idle-view?
Title: Re: How to use blink view?
Post by: Ishmael on Wed 05/10/2005 15:39:58
The blinking view is displayed every BlinkInterval during the character's speech, and thinking if BlinkWhileThinking is true. It's a bit confusingly said in the manual, but it is there...
Title: Re: How to use blink view?
Post by: fovmester on Thu 06/10/2005 05:37:11
so if I want my character to blink when he's not talking I have to use idle-view?
Title: Re: How to use blink view?
Post by: strazer on Thu 06/10/2005 08:37:05
Or, if you want all characters to have an idle view as well as blinking, you can try out this early version of a script module (http://www.strazer.net/ags/CharacterBlinking.zip) for AGS v2.7 I have been working on.

Import the script module via menu "Script" -> "Module manager...".

Put the blinking animation for each direction into the character's normal (walking) view, beginning at loop 8:
loop 8: blinking down
loop 9: blinking left
loop 10: blinking right
loop 11: blinking up
loop 12: down-right
...
and so on.

Then, to start the blinking (in game_start for example):


  CharacterBlinking.Enable(cRoger);


- The blinking delay is randomized between 2 and 5 seconds
- The blinking will only play when the character not moving, not animating and not playing the idle animation
- Use CharacterBlinking.Disable to stop a character from blinking

The module has not been fully tested yet, so there may still be bugs to work out.
Title: Re: How to use blink view?
Post by: fovmester on Fri 07/10/2005 05:55:24
Sounds exactly like what I want to accomplish! Thanks, strazer!! :)
Title: Re: How to use blink view?
Post by: fovmester on Fri 07/10/2005 06:35:09
I tried your module out, and it was sweet. I found a bug though: After finishing blinking, it does change the loop back to the old one, but not the frame. Fix:


function repeatedly_execute_always() {

int charid = 0; // start with character 0
while (charid < GetGameParameter(GP_NUMCHARACTERS, 0, 0, 0)) { // loop for each character

if (cbCharacter[charid].blinking == true) { // if character has blinking enabled

if ((character[charid].Moving == false) && (character[charid].Animating == false) && (character[charid].View != character[charid].IdleView)) {
  // if character is not walking, not animating (blinking) and not playing idle animation

if ((character[charid].Loop >= BLINKING_LOOP) && (character[charid].Loop <= (BLINKING_LOOP+3))) { // if character was blinking
character[charid].Loop = cbCharacter[charid].blinkoldloop; // restore old loop
character[charid].Frame = 0;   // <<<<<<<< ADDED THIS ROW. /FOVMESTER
}

if (cbCharacter[charid].blinkdelay == 0) { // if delay until next blink has elapsed
cbCharacter[charid].blinkoldloop = character[charid].Loop; // store current loop for restoring after the blink
character[charid].Animate(character[charid].Loop + BLINKING_LOOP, 0, eOnce, eNoBlock); // animate using blinking loops of normal view
// Using loops of the normal view avoids the need for seperate blinking views and unlocking the blinking view
cbCharacter[charid].blinkdelay = (BLINKING_DELAY_MIN + Random(BLINKING_DELAY_MAX - BLINKING_DELAY_MIN)) * GetGameSpeed();
  // randomize delay until next blink
}
else cbCharacter[charid].blinkdelay--; // if blinking delay has NOT yet elapsed, decrease it

}

}

charid++; // loop to next character
}

}
Title: Re: How to use blink view?
Post by: strazer on Sat 08/10/2005 17:49:41
Thanks. Above version now contains your fix.