Results 1 to 10 of 26

Thread: State machine - requesting advice

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #21
    Figured it out, you need to have virtual; at the end of the TState methods. If you also add them abstract; , then you don't need to make them implementation code at all. But that is only useful tip if you never plan to add them any code, and also if they're abstract, then they must be defined in all inheriting classes.

    Can't see the source for segfault if you did also what SilverWarior said.

    1 other tip that i could give, is making new unit for TState alone. Then you can use the same state-machine in all your projects. You could move the CurrentState variable there, and also make a universal procedure like
    Code:
    procedure RunStatesApp;
    begin
          repeat
            CurrentState.BeforeDraw;
            CurrentState.Draw;
            CurrentState.Main;
          until quit;
    end;
    that you would call from main program unit.
    (Make sure there are no uses-list's in the universal state-unit)
    Last edited by User137; 29-06-2013 at 11:28 AM.

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
  •