Dear Athena,
I tried to get it right but no joy, I'm sending my code to your e-mail address and will appreaciate it if you will have a look for me.
Thank you :-)
Dear Athena,
I tried to get it right but no joy, I'm sending my code to your e-mail address and will appreaciate it if you will have a look for me.
Thank you :-)
Wake up from the dream and live your life to the full
Hi Wizard,
You're gonna kick yourself I'm afraid.
There doesn't appear to be any faults with the man moving code, except an additional begin/end around the loop (commented out in the code below).
[pascal]
// begin
if (MyMen.count>0) then
for loop:=MyMen.count-1 downto 0 do
begin
TMan(MyMen[loop]).DoMove(1);
end;
// end;
[/pascal]
Not that these make any difference, but they could confuse other stuff like syntax highlighters and such.
The problem actually stems from the creation. You have this code for creating the men.
[pascal]
Man:=TMan.create(30,-500,'man1',DXSpriteEngine1,DXImageList1);
[/pascal]
I've made the same mistake you've made plenty of times and spent hours hunting for 'bugs'. What you actually need to do is, instead of allocating the newly created sprite to a variable, just add it to your MyMen TList. Like so.
[pascal]
MyMen.add(TMan.create(30,-500,'man1',DXSpriteEngine1,DXImageList1));
[/pascal]
If you don't add them to the list, MyMen is empty when the code checks for man sprites and so they stay at their starting positions indefinitely :-)
:: AthenaOfDelphi :: My Blog :: My Software ::
Athena you are brilliant as allways :-)
I could'nt understand the use of MyMen in the loop to move because there was nothing assigned to MyMen...if it wasn't for you I probably would have spent hours on it too :-)
It works like a charm.....my little men and monsters have been released from the invissible world they were in :-)
Have a good day and thanks again :-)
Wake up from the dream and live your life to the full
Bookmarks