2 Replies Latest reply on Jan 31, 2012 4:11 AM by Jhon Carlo

    Block two sprites if they intersect

    Jhon Carlo Level 1

      Hello,

       

      I have several sprite which I can drag with mouse, if some sprite "intersect" another one this sprite is blocked, if not, the sprite which I'm carrying, go tho the position before of my first click.

      I write different script but I send a schematic one to try to understand what doesn't work:

       

      on mouseUp me

        if sprite(me.spriteNum).intersects(10) = true then

          sprite(me.spriteNum).rect = sprite(10).rect

        end if

        if sprite(me.spriteNum).intersects(11) = true then

          sprite(me.spriteNum).rect = sprite(11).rect

        end if

        if sprite(me.spriteNum).intersects(10) = false then

          sprite(me.spriteNum).rect = rect(95, 175, 156, 245)

        end if

        if sprite(me.spriteNum).intersects(11) = false then

          sprite(me.spriteNum).rect = rect(95, 175, 156, 245)

        end if

      end 

      Thanks.