5 Replies Latest reply on Aug 12, 2008 9:27 AM by Gregory Lafrance

    movement image logic

    Varangian Level 1

      I'm doing a game, and been using flex 2-3 (upgraded to 3 now).

      I came across the movement of an image. This is image basically moves using the mx:Move. Now for every amount of pixels I have to check if this image collides with other image display objects....so what I doing is this.

      1) set mx:Move xFrom and yFrom to current image x and y
      2) set mx:Move xTo and yTo to x + 1 and y + 1
      3) then mx:Move play
      4) after playing the mx:Move moves by 1 - fires the event endEffect..
      5) check for collisions and other logic
      6) repeats step 1 - 6.......
      and continues this whole thing until reaching the destination...

      I gave the mx:Move duration to "1" .. and it's slow on 1.6 pc with 512 ram.. while on quad core it is very fast.

      A problem with this is that the it wouldn't be the same on every pc....

      Is this the best approach in handling such situation?

      I tried using the tweenEffect event, however it is a bit buggy since if the image collides I need to end the movement event and then suddenly puts the image object on the destination it was heading which doesn't make sense.
      And also with the tween effect the image doesn't move in a continuous motion, sort of takes some time at first and then continues accelerating until it gains some speed and fires like a bullet which is not what I really want.

      Anyone has ever met with this kind of logic? What did you people when moving things and have to check (almost) every pixel for collision? Any hindsight?

      Thanks (heh for reading a tedious long post)