Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On stage sprite swapping

Status
Not open for further replies.

bitphire

Programmer
Apr 19, 2005
4
US
Hi I am doing a simple game and I am using gif animations for the different positions. Person standing is just a standard gif picture no animation. When a user hits an arrow key the sprite switches to the walking sprite. I am using sprite(2).membernum = 5. This works great besides that the bounding boxes are different sizes. So when I put a certain animation into another sprite it will shrink or expand the picture. Is there a way around this with out redoing the gif animations? TIA for any help. :)

Steven
 
I am using MX 2004. I think maybe you mis understood me. I use an animated gif for standing still. (charatecer kinda sits and rocks back and forth) Then I do sprite(2).membernum = 5 when lets say an arrow key is pressed. Membernum 5 is another animated gif but of the player walking. When it does the switch it sometimes stretches or compacts the image to fit into the original sprites bounding box. I was just wanting a fix to this with out re doing all my gif animations. Thanks for the help.
 
I don’t think I misunderstood you but as Director does not change the dimension of member unless you tell so, I thought either you’re using very old version or doing something strange with your code…!

It’d be nice to pin down the reason behind your problem, however you can force the size of your “walking” GIF animation to the original size after swapped from “sitting” GIF animation.

(movie script)
--
global gWidth, gHeight

on startMovie
gWidth = member(5).width
gHeight = member(5).height
end startMovie

on keyDown
if _key.keyCode = 124 then
sprite(2).memberNum = 5
sprite(2).width = gWidth
sprite(2).height = gHeight
end if
end keyDown
--
NB. member(5) is your “walking” animation and your “sitting” animation is in the sprite(2). KeyCode 124 is the right arrow key.

Kenneth Kawamoto
 
Hey I think that is what I needed. I don't have my code to copy paste right here but I will do a simple version of it so you can see. This would be on sprite 2 which is my character.

on exitframe

if keypressed(124) then
sprite(2).membernum = 5
sprite(2).loch = sprite(2).loch + 4
else if keypressed....

That is really all the code I have so far for the game. When I put member 2 and 5 on the stage and compare the bounding box that surrounds the sprite I can see that 5 is larger than 2. So it is forcing member 5 to fit in the bounding box of 2. (I am sure you already know this) I think your fix might work. Also, how would you compare this to maybe a walk-cycle? I read about it somewhere and not sure if I should try to do that instead. I think it is where you put a still image in a seperate frame to make a loop and create cast for each movement. Let me know if I am way off. Thanks
 
Alright now I am really confused. I seperated the animated gif into 5 still images. I imported all 5 of them into a director movie. I placed them in the score. I have these names:

BushKick
BushKick2
BushKick3
BushKick4
BushKick5

I put BushKick on frames 1-5
BushKick2 on frames 6-9
BushKick3 on frames 10-12
BushKick4 on frames 13-15
BushKick5 on frames 16-19

This basically makes the same as the animated gif. Maybe I misunder stood by I was think this is how it should be done. My only problem is that I not sure how to use it. I don't know any more. I am confused. Is this a correct way to make a loop? I need to have collision detection. Any suggestions? My problem is when they player wants to go from walking to a kick out do I make this happen?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top