Offset animating view (climbing down stairs) use Lockview?

Started by Ryan Timothy B, Sat 08/03/2008 21:32:29

Previous topic - Next topic

Ryan Timothy B

Ok my game has been on hold for a month now because I am sure I am going at something the wrong way and don't want to keep moving until I know how to do this properly.

I have my ego standing at the top of some steps, and he climbs down them.  Look at picture below.



The two smaller rectangles are the (approximate) border of the idle view of the ego looking left.  And the big rectangle is the border of the animation of him climbing down the stairs (which isn't shown here).

I am more than likely over looking the forums incorrectly and just can't find the help I'm looking for.

This is the code I'm using:

Code: ags

 cEgo.Walk(234, 125, eBlock);   //him walking to top of steps before animation
 cEgo.x=cEgo.x-18;  //this is what I really don't like.. it changes his xy BEFORE it sets the Large animation view
 cEgo.y=cEgo.y+26;
 cEgo.LockView(7);  //locking the view to the animation
 cEgo.Animate(2, 5, eOnce, eBlock);
 cEgo.x=cEgo.x-15;  //position the ego off to the left so unlock view can have him standing where he should be
 cEgo.UnlockView();


Oh and at the end he is facing Right (loop 2 on ego view, also the loop used in the climbing animation?).  Which in the description of Lockview it shows nothing about having to set the view loop again when unlocking.

I was wondering if I should just have the character visible = false, animate an 'object' of the him climbing down the stairs, make the visibility of that false, enter the new location of my character and make him visible.  Is that how the professional AGSers do it?

Pumaman


Play_Pretend

The second and third lines of your code are to offset him because when he shifts to his stair-climbing view, the character jumps to the right and up, correct?  I've had this same problem a lot.

One relatively easy workaround is to make another character called cEgoStairs or something, who only has one view, the walking-down-the-stairs cycle.  In CEgoStairs' character info, set his beginning coordinates as the room with the stairs, and an x,y position that will put him off the edge of the screen.  When the player clicks on the stairs (or walks onto the region in front of them or whatever):

- Have your cEgo walk to the top of the stairs
- Change cEgo's x,y position off the edge of the screen
- Set cEgoStairs x,y as the exact spot cEgo just left
- Run cEgoStairs walking-down-stairs animation
- Change cEgoStairs x,y back off screen again
- Change cEgo x,y to the position at the bottom of the stairs

So basically, you're just jumping your player off the edge of the screen, jumping in a double, having him walk down, then instantly jumping him away and replacing him with your player again.  You don't have to worry about FaceLocation problems or messing about with your player's views or offsets.

Of course, you'll have to reverse it all for climbing back up the stairs.  You could give cEgoStairs a climbing-up view too, or just create a cEgoStairs2 character. :)

Not too complex, and it's solved a lot of my animation problems in the past.

Ryan Timothy B

Sorry if I didn't make any sense there, Chris.

So having an extra character is what I should do for an offset view animation, Strange Visitor?  Thanks.

SMF spam blocked by CleanTalk