Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

How do I make 4 frames repeat themselves in java?

Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to add 4 frames to run in a cycle so it seems as if my character is running on the spot but I don't know how to do this with more than 2 frames.

here is my code, what should I adjust to it so it works and that its bug free?

Posts: 70684
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our GUIs forum.

You can have an array of images. Try a Timer to make the frames appear in turn. You can have an index and use the remainder operator to bring it back to the beginning of the array.
Don't make the timer fire more frequently than about once per 20ms or once per 25ms. Your four‑element array would move far too fast at that speed. You can try about once every 100ms, but I think your animation will be horribly jerky. Is there any way you can interpose more frames and make the motion smoother?
What does Bitmap mean?
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic