locked
Wth is going on??! RRS feed

  • Question

  • hi! i have a problem with my code!

    the smoke particles wont fade out when the particles hit the circle! emit steam thowards the circle, and see what happens!

    i have abolutely no explanation why this is happening...

    XMQ437
    Live for nothing, OR CODE FOR SOMETHING!
    Thursday, November 19, 2009 9:53 PM

Answers

  • The main reason is that as you delete a shape you increment Steam_Old, but the one you delete may not be the first created, this is because you can reduce the opacity of the shapes at different rates depending on their distance (and hence initial velocity).

    If you have Steam_Old = 0 at the start and 3 smokes created in order s = 1, 2, 3.  But smoke s=2 is slow and fades faster, it is deleted and Steam_Old is set to 1, so next time you only check s= 2 and s=3 (s=1 is just left there and s=2 is already deleted).

    Try the following

        If Steam_Distance[s] <= 25 Then
          Steam_WX[s] = Steam_WX[s]*0.65
          Steam_WY[s] = Steam_WY[s]*0.65
          Steam_Zoom[s] = Steam_Zoom[s] * 1.01
          '  Comment this out Steam_Opacity[s] = Steam_Opacity[s] - 2
        endif
       
    Also you should do the delete for Steam_Rotation[s] = ""

    And, I would do the Shape update for s, before potentially deleting the shape.
    • Marked as answer by Dudeson Friday, November 20, 2009 5:02 PM
    Thursday, November 19, 2009 10:21 PM

All replies

  • The main reason is that as you delete a shape you increment Steam_Old, but the one you delete may not be the first created, this is because you can reduce the opacity of the shapes at different rates depending on their distance (and hence initial velocity).

    If you have Steam_Old = 0 at the start and 3 smokes created in order s = 1, 2, 3.  But smoke s=2 is slow and fades faster, it is deleted and Steam_Old is set to 1, so next time you only check s= 2 and s=3 (s=1 is just left there and s=2 is already deleted).

    Try the following

        If Steam_Distance[s] <= 25 Then
          Steam_WX[s] = Steam_WX[s]*0.65
          Steam_WY[s] = Steam_WY[s]*0.65
          Steam_Zoom[s] = Steam_Zoom[s] * 1.01
          '  Comment this out Steam_Opacity[s] = Steam_Opacity[s] - 2
        endif
       
    Also you should do the delete for Steam_Rotation[s] = ""

    And, I would do the Shape update for s, before potentially deleting the shape.
    • Marked as answer by Dudeson Friday, November 20, 2009 5:02 PM
    Thursday, November 19, 2009 10:21 PM
  • damn! youre right! i absolutely forgot about that!


    and i always wondered, is there a way to make them disappear at different rates without affecting the other sprites??
    Live for nothing, OR CODE FOR SOMETHING!
    Friday, November 20, 2009 1:55 PM
  • There is always a way, usually several.  Here's one:

    If (Steam_Opacity[s] <= 0 And s = Steam_Old+1) Then


    This only deletes the sprite when it is the first created in the list - if others disappear before they are deleted - no problem since they will be deleted soon enough.
    Friday, November 20, 2009 7:04 PM
  • wow! thx!

    really nice and simple solution!

    the bad thing is just that the code will be executed till s = Steam_Old+1 ... but thats not really a big performance impact..

    Live for nothing, OR CODE FOR SOMETHING!
    Friday, November 20, 2009 8:05 PM