Logic of Player movement
Blitz3D Forums/Blitz3D Beginners Area/Logic of Player movement
| ||
Hi there, I've been looking at Imagepacker - http://homepage.ntlworld.com/config/imagepacker/ and it is really good. I got a small character who has 2 image in a 'pack'. He has a standing animation and a running animation, I'm getting stuck on the logic behind this, and wondered if anyone could help. Here is my bit of code My logic is flawed here with the changesprite, and I wondered what many people do when they want to change the character animation, when clicking on the right cursor. Any help would greatly be appreciated Many thanks |
| ||
Wouldn't it be easier to have both the animation sequences in one sequence.. eg: 1 - 6 walking animation 7 - 12 running animation When you want him to run you just bump the frame index by 6 so it then indexes the running animation (7 to 12) and return it to the default when he's walking (1 to 6). |
| ||
Hi Yeshu777, Wow freaky, that was my line of thinking just right at this moment, this may be the easiest way of doing it Just wondered if there was another way using ChangeSprite commands. Thanks :) |
| ||
You're welcome. |
| ||
Mmm I have tried this, the problem with this, is that the hero animation are all in different sizes, so the imagepacker was a godsend in this part. |
| ||
So does it work? |
| ||
Hi there, I have been checking over the weekend regarding this, for the walking animation, yes it did work, as there was all the same height and length, however the standing animation isn't. The width is bit different, which is why I thought about using imagepacker instead. |
| ||
Ahh I think I have figured this out, rather than having one long strip, I broken it up, so I have global hero global hero_standing=LoadAnimImage("standing.png",8,10,10,10) global hero_walking=LoadAnimImage("walking.png",10,10,10,10) While Not KeyHit(1) Select hero_change Case 1: hero=hero_standing Case 2: hero=hero_running End Select If KeyDown(205) Then hero=2 wend That works out, but is there a function to say, if not keydown or keypressed, then hero_standing. |
| ||
Something like this?..If( KeyDown(205) ) Then hero_change = 2; Else hero_change = 1; End If |
| ||
Doh!! Yeshu777, that is soo simple, of course :) :) Nice one :) |
| ||
Alternatively (and if you still want to use seperate animation sequences) you could try this...Dim hero[5] global hero[1]=LoadAnimImage("standing.png",8,10,10,10) global hero[2]=LoadAnimImage("walking.png",10,10,10,10) global hero[3]=LoadAnimImage("shooting.png",10,10,10,10) global hero_idx=1; While Not KeyHit(1) If( KeyDown(205) ) Then hero_idx = 2; Else hero_idx = 1; End If PositionSprite(hero[hero_idx], x, y) ; Your sprite function etc... Wend Well, you get the basic idea... |