Results 1 to 4 of 4

Thread: two timers at time

  1. #1

    two timers at time

    i created a game using simple timer, but then i decided to change it into DXTimer, but in my project is 4 timers. one if hero go tu north, other if hero go to the south..... and i need to run two timers but it dosen't work. with simple timer everything was ok how to run two dxtimers?
    http://www.programuotojas.com

  2. #2

    two timers at time

    While TTimer is based on Windows messages, DXTimer (if I remember correctly) uses OnIdle event, making only one of these usable at a time. Using many timer's is not really a good idea anyway, it's much better to make one fast timer and put everything timing related in it's OnTimer event, like:

    [pascal]if Action1Enabled then
    begin
    inc(Action1Time);
    if Action1Time > Action1NeededTime then
    begin
    DoAction1;
    Action1Time:= 0;
    end;
    end;

    if Action2Enabled then
    begin
    inc(Action2Time);
    if Actio2Time > Action2NeededTime then
    begin
    DoAction2;
    Action2Time:= 0;
    end;
    end;[/pascal]etc.

  3. #3

    two timers at time

    well you see i need 4 timer, i don't know how to change them to one. for example if hero is in [0, 0] and he need to go to [5, 9] xtimer and ytimer will be enabled while hero reaches [5, 5] then xtimer.enabled := false; and only ytimer will be active.
    http://www.programuotojas.com

  4. #4

    two timers at time

    Change Action1Enabled to Xcurrent <> Xwanted, etc.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •