event based timer
Martin Nowak
dawg at dawgfoto.de
Wed Jul 20 03:05:28 PDT 2011
Well, I guessed right I think. In you're main file you are using global
//VARIABLES but in fact they are thread local.
That is each thread has it's own copy of them, so that different threads
don't mess up each others data.
You can try the other timer approach or solve your sharing.
It would be really better if phobos had some kind of timer. The thread
solution is really suboptimal.
On Wed, 20 Jul 2011 11:20:24 +0200, maarten van damme
<maartenvd1994 at gmail.com> 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>
>
>> 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.
>>
>>
>>
More information about the Digitalmars-d
mailing list