Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: How to move a list?

  1. #11

    How to move a list?

    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

  2. #12
    PGD Community Manager AthenaOfDelphi's Avatar
    Join Date
    Dec 2004
    Location
    South Wales, UK
    Posts
    1,245
    Blog Entries
    2

    How to move a list?

    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 ::

  3. #13

    How to move a list?

    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

Page 2 of 2 FirstFirst 12

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
  •