• 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 ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Periodically adding to a variable  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to see if I could create a simple idle game similar to Cookie Clicker. I need to know two things.

1.) How would I have a variable have something added to is every second or so on a repeated indefinite basis?
2.) How would I start the JavaFX GUI and have that constant addition run in parallel to other tasks, such as buying things to generate cookies faster, or whatever item I base it on.
 
Marshal
Posts: 5987
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer one: depends on what you're doing.  If the process has nothing to do with the UI, then use a java.util.Timer and and TimerTask:
If you are incrementing a variable so as to animate something in the GUI, use javafx.animation.AnimationTimer or javafx/animation/Timeline.
 
Knute Snortum
Marshal
Posts: 5987
155
Chrome Eclipse IDE Java Postgres Database Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer two: I don't know exactly.  There are two ways to create GUIs in JavaFX: one is within the code and the other is to use FXML.  The latter is static, though, so you might want to set up your initial scene with it and then manipulate the scene graph in code.  Or do it all in code.  I have done only the most basic GUI animation, so hopefully someone more experienced will answer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!