how to make a walk cycle for a 2d game between 2 frames( right_leg_up.png and left_leg_up.png) for a character
-thanks
You’ll need to give a lot more details than that.
. . . Are you trying to animate 2 images you’ve already drawn, within your game? . . . If so, what are you using? LibGDX, Slick2d, jMonkeyEngine, pure java?
. . . Are you trying to DRAW the images? . . . If so, top down, isometric, side scrolling? . . . what style? Pixel art, cartoony, realistic, 2.5d?
im writting a java game (2d…simple stuff…) and i would like 2 make my char move his legs while he moves (walk cycle) i’ve already 2 png files with
diffrent positions of the char’s legs between which i would like to switch while he moves to vk_right, so what do i do to make it switch between those 2 frames while he moves to right…?i ve tried to use a “switch” but i got some errors
-if you have a solution, pls explain as if i am really bad at programming, because im new… and i kinda suck right now…
-i’ve asked for help about this in many forums but i was told that “this is the place”
idk if it helps but im using eclipse as a compiler
-thanks
Perhaps you should be starting with something simpler.
Try making console-based games to get the feel of programming.
just create an array of images like:
Image[] sprites=new Image[2]
and then create a timer that changes a variable that just alternately switches between the two image array.
btw, that array creates two slots but they are called like sprites[0] and sprites[1] or like sprites[var] with var ranging from 0 to 1
here is some information on Swing Timers
and some information on arrays
Hope this helps at all.
Believe it or not, animation is a fairly complicated subject, even more so for someone who is brand new and doubly so if you’re not using something like Lib or Slick.
But, basically what you need to do is make an image array the size of however many frames your image is for every angle you want to animate (IE: walkingRight, walkingLeft, walkingUp, walkingDown), and then load each image into it. Once you do that, you can put a timer in your update loop that swaps out between 1 image and the other. But you also have to have a way to know what direction you’re moving/facing to load other images for other directions. Believe it or not, animation is a topic that is very complicated to explain from the bare basics all the way to the end. I highly suggest checking out some coding tutorials before progressing into graphic based games.
These videos go super slow, but will really help you get a foundation going, I suggest watching every single one, then coming back to your project
http://thenewboston.org/list.php?cat=31 <–Total newbie stuff
http://thenewboston.org/list.php?cat=25 <–more advanced stuff
http://thenewboston.org/list.php?cat=30 <–Concepts on making a game from scratch
http://thenewboston.org/watch.php?cat=30&number=7 <–Start here for more-specific info to your question, probably better explained than I can in text on a forum. Watch this video plus the next few after it and it’ll explain the concepts of animation in pure java.
http://thenewboston.org/list.php?cat=54 <–Intro to using Slick2d (Not recommended since Slick2d is mostly not used anymore)
thanks 4 the info