event based timer

Chris Molozian chris at cmoz.me
Wed Jul 20 03:24:02 PDT 2011


As you're creating a Gtk app, have you considered using glib.Timer 
<http://gtkd.mikewey.eu/src/glib/Timer.html> or glib.Timeout 
<http://gtkd.mikewey.eu/src/glib/Timeout.html> (depending on your 
needs)? I do almost all my Gtk development in Vala these days, so I 
haven't used them from D (so not sure if you've encountered problems 
with them).

Cheers,

Chris


On 07/20/11 10:20, maarten van damme wrote:
> Thanks a lot, now those errors are gone. Still it refuses to work 
> properly...
> I have a method clockTick in Main.d and that should be called every 
> 0.1 seconds, when I place a call to that method in a onmousenotify 
> event(when the mouse moves) It runs correctly apart from the odd fact 
> I need to move my mouse to play the game.
> When I use that method in the timerclass it reaches only the lines 
> where I print something in the console but doesn't go any further 
> without giving any errors.
>
> The complete code can be seen at:
> http://dl.dropbox.com/u/15024434/d/Main.d
> http://dl.dropbox.com/u/15024434/d/Timer.d
> http://dl.dropbox.com/u/15024434/d/Sprite.d
> http://dl.dropbox.com/u/15024434/d/Bain.d
> http://dl.dropbox.com/u/15024434/d/PingPongBox.d
>
> The code for the timer in Main.d is at line 63
> clockTick method in Main.d is at line 93
>
> 2011/7/20 Daniel Murphy <yebblies at nospamgmail.com 
> <mailto:yebblies at nospamgmail.com>>
>
>     private void  function() *  callBack;
>
>     should be private void  function() callBack;
>
>     void function() is a function pointer, void function()* is a
>     pointer to a
>     function pointer.
>
>     On lines 23 and 41, you shouldn't be dereferencing callBack.  Just use
>     callBack() to call the function and 'this.callBack = callBack' to
>     set it.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110720/c5d10d2e/attachment.html>


More information about the Digitalmars-d mailing list