Jump to content

Game ticks


Recommended Posts

Posted (edited)

Does anyone know how to implement a game tick counter? This is what I tried, but it seems like onGameTick() is never called (tickCount never increments).

Class Declaration:

	class GameTickCounter implements GameTickListener{
    private int tickCount = 0;
    
    @Override
	    public void onGameTick(){
        this.tickCount++;
    }
    
    public int getCurrentTick(){
        return this.tickCount;
    }
}
	

 

Object Init in main:

private GameTickCounter tickCounter = new GameTickCounter();

 

Implementation:

	if(tickCounter.getCurrentTick() > currentTick){
    currentTick = tickCounter.getCurrentTick();
    log("Tick: " + currentTick);
	}
	

Edited by iamonkey

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...