Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
non timer — Gideros Forum

non timer

JackoJacko Member
edited September 2015 in Suggestions & requests
Are there any way, to check condition ,every second without timer.new?

Comments

  • @Jacko Enterframe event and os.timer() within an if condition, where you check the current os.timer against a previously taken os.timer value. if the difference between those is> 1000, a second should ve passed.
    You could also use timer with infinte loop and act on event.timer if your problem is that you have too many timers around
  • This will do it for you...
    function myEnterFrame(event)
    	if event.frameCount%application:getFps()==0 then
    		print("blah")
    	end
    .
    .
    .
    .

    Likes: pie

    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
    +1 -1 (+1 / -0 )Share on Facebook
  • @SinisterSoft I apologize for my stupidity, but didnt print
  • Thanks to @SinisterSoft ,
    @Jacko , I think it should be like this
    Ball = Core.class(Sprite)
     
    function Ball:init(texture)
    	--some code
     
    	self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
    end
     
     
    function Ball:onEnterFrame(event)
    	--some code
     
    	if event.frameCount%application:getFps()==0 then
    		print("blah")
    	end
    end

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
  • SinisterSoftSinisterSoft Maintainer
    edited September 2015
    @Jacko Sorry, I thought you would guess it was supposed to be in the main enterframe event...
    function myEnterFrame(event)
    	if event.frameCount%application:getFps()==0 then
    		print("blah")
    -- Here stuff will be execute once every second
    	end
     
    -- Here you can do more stuff that needs to be execute every frame!
     
    end
     
    stage:addEventListener(Event.ENTER_FRAME,myEnterFrame)
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • Thank you guys:)

    Likes: SinisterSoft

    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.