Community
SCI Programming => SCI Syntax Help => Topic started by: jtyler125 on April 17, 2007, 09:05:45 PM
-
This is a question for the best way to add an animation, for example have a golfer walk up to the tee box, you type "hit ball" this causes ego to disappear and then the animation takes a swing...and then after that ego reappears.
right now I am using an if said statement
with something like (this is not what I really have but I think you get the idea):
(if (Said 'hit/ball')
(seng gEgo:hide)
(Golfswing:init())
(SetUp gEgo)
)(else
Print('Your not close enough.")
Blah blah blah...
The problem is the golfer swings...and then ego is still hidden.
What am I doing wrong?
Any takers....
The best response would be to paste a part of your own script that works...as a response...also not sure how to apply a method change state...to allow for the clip to stay on the screen for a few sends to play the full animation and then disappear again to put the ego back on the screen to continue on with the game.
Thanks,
JT
-
If I understand correctly, you don't want to make the ego disappear, just to change to a different view (the swinging animation). But just to be clear, instead of (SetUp gEgo), the code that would make the ego reappear would be (send gEgo:show()).
For your purposes, the best thing to do is set up a changeState method:
(method (changeState mainState)
= state mainState
(switch(state)
(case 0) // since there's no case 1 identified, it won't go to case 2 unless told
(case 2 = seconds 1 //or however long you want the animation to be
(send gEgo:view(#)loop(#)cel(0)setCycle(End)) // change ego to animation view
(ProgramControl) // player will not be able to move or type during animation
) // end case 1
(case 3
(send gEgo:view(0)loop(#)cel(#)setCycle(Walk)) // change ego back to walking view
(PlayerControl) // give player back ability to move and type
) // end case 2
) // end switch(state)
) // end method
That would be the basic code to change the Ego to a different view for some animation, and to get the game to do it is pretty simple...you use the same (if(Said())) thing, only if the player did input 'hit/ball', you do (RoomScript:changeState(2)), which will then run the animation code.
-
Ok this is the exact place where you put it...thanks Doan:
(instance RoomScript of Script
(properties)
(method (changeState whatevertheanimationnameis)
= state whatevertheanimationnameis
(switch(state)
(case 0) // since there's no case 1 identified, it won't go to case 2 unless told
(case 2 = seconds 3 //or however long you want the animation to be
(send gEgo:view(6)loop(0)cel(0)setCycle(End)) // change ego to animation view I chose view 6
(ProgramControl) // player will not be able to move or type during animation
) // end case 1
(case 3
(send gEgo:view(0)loop(0)cel(0)setCycle(Walk)) // change ego back to walking view Ego is view 0
(PlayerControl) // give player back ability to move and type
) // end case 2
) // end switch(state)
) // end method
(method (handleEvent pEvent)
(super:handleEvent(pEvent))
(if(Said('wave'))//my animation was to make Ego wave when you typed wave
(RoomScript:changeState(2))
)
)
)
Thanks,
JT
-
OK doan now I have a different question...I want to get in a boat in one room and then have the ego still be in the boat in the next room, how do I accomplish that. It can be cheap and easy and the Ego never has to be a regular walking ego in the room where he is in the boat...so is there a way to init the ego as the new view...I keep getting messed up.
JT
-
There are probably a few ways to do this, but here is what I would do:
set up in the main script a variable like:
gInBoat = 0Then, in the handleEvent method for the room with the boat,
(if(Said('get/in'))
Print("OK")
= gInBoat 1
(send gEgo:view(8))
)Then, in all the rooms where you may be in the boat, you can set up in the init(method) code like this:
(if(gInBoat)
(send gEgo:init()view(8))
)(else
(send gEgo:init()view(0))
)That's pretty barebones, but I think it should work...let me know if you need more help with this.