Jump to content

Timer based on frames, not ms


farzher
 Share

Recommended Posts

My game is exploitable when played at low framerate, because everything slows down, except the timers.

 

Can I use a timer that's based on frames, not ms? Or am I expected to just code that myself? You have a nice timer class, it'd be great if I could use it.

Link to comment
Share on other sites

Instead of messing with your timer class, I think it'd be easier to make my own frametimer object.

Is there an empty gameobject class I can extend? I didn't see one, the only way I know how to do this is using a sprite:

I want to make an empty game object, give it an amount of frames and a callback, it'll add itself to the game so update gets called on it, then it'll call the callback and destroy itself when it's done.

Link to comment
Share on other sites

How do I fix the performance of this? This is pretty bad haha.
I'm adding an image to the game to get update called on it. Idk how else to know when frames a frame passes.

# TODO: performance is badclass FrameTimer extends Phaser.Image	(@duration, @callback, @context) ->		super game		@frameCount = 0		game.add.existing @	update: ->		@frameCount += 1		if @frameCount > @duration			@callback.call @context			@destroy!

It's used like this, and works well:

new FrameTimer @reloadSpeed, (-> @canShoot = true), @
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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