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)
Bookmarks