Anonymous user
Scripting, Code & Interaction: Difference between revisions
→Having a character continuously animated in the background
Line 240: | Line 240: | ||
Heh just kidding. You can use the character's idle animation to do this. Simply set up his/her idle animation ('''SetCharacterIdle()''', or '''cEgo.SetIdleView()''' for AGS V2.7 and above) with the idle delay to "0" so that it plays constantly. Voila! You now have a repeatedly animating background character with only one line of script. If you wanted, for example, a character in the background to do a one-time animation randomly with pauses between, set the idle delay to a higher number. The higher the idle delay, the longer between idle animations AGS will wait. | Heh just kidding. You can use the character's idle animation to do this. Simply set up his/her idle animation ('''SetCharacterIdle()''', or '''cEgo.SetIdleView()''' for AGS V2.7 and above) with the idle delay to "0" so that it plays constantly. Voila! You now have a repeatedly animating background character with only one line of script. If you wanted, for example, a character in the background to do a one-time animation randomly with pauses between, set the idle delay to a higher number. The higher the idle delay, the longer between idle animations AGS will wait. | ||
'''Edit by monkey_05_06''' | |||
As an alternative to this method (which destroys the idle view delay) you can do this instead: | |||
// in repeatedly_execute_always | |||
// AGS 2.7 and higher | |||
if (Character.SpeechView > 0) { | |||
Character.LockView(Character.SpeechView); | |||
if (!Character.Animating) | |||
Character.Animate(Character.Loop, Character.AnimationSpeed, | |||
eRepeat, eNoBlock, eForwards); | |||
} | |||
// AGS 2.62 and lower | |||
if (character[CHARACTER].talkview > 0) { | |||
SetCharacterView(CHARACTER, character[CHARACTER].talkview); | |||
if (!character[CHARACTER].animating) | |||
AnimateCharacterEx(CHARACTER, character[CHARACTER].loop, | |||
character[CHARACTER].animspeed, 1, 0, 0); | |||
} | |||
Of course you would replace: | |||
(AGS 2.7 and higher) | |||
'''Character''' with the script o-name of the character (or ''character['''ID''']'' where '''ID''' is the ID of the character). | |||
(AGS 2.62 and lower) | |||
'''CHARACTER''' with the script name of the character. | |||
So if you use the idle view and have a delay set for the animation, this is the safer alternative. | |||
==Taking away score points.== | ==Taking away score points.== |