1 Reply Latest reply on Jan 19, 2007 4:16 AM by Newsgroup_User

    Drag & Drop Game - I'm stuck!

    Dava Level 1
      Hello.

      I'll try and explain this as simply as I can!

      I have a drag and drop game where you have to drag one of 4 items into a bag. If you chose the right item and drag that into the bag, you'll jump to a specific marker which says CORRECT. If you drag any of the other 3 items, you'll jump to a marker that says FALSE. In other words, for each item I need it to jump to a different marker when you've dragged it in.

      At the moment I've managed to get it working so it jumps to the marker, but it jumps to the same marker which ever item you drag. I need them to be different.

      >> I HAVE THIS SCRIPT ON MY DRAGGABLE ITEM:

      end beginSprite

      on endSprite(me)
      (the actorList).deleteOne(me)
      end endSprite

      on mouseDown me
      pOffset = pSprite.loc - the mouseLoc
      (the actorList).append(me)
      end

      on stepFrame(me)
      if the mouseDown then
      pSprite.loc = pOffset + the mouseLoc

      else
      sendAllSprites(#DropSprite, the mouseLoc)
      pSprite.loc = pStartLoc
      (the actorList).deleteOne(me)
      end if
      end stepFrame


      >> I HAVE THIS SCRIPT ON MY TARGET AREA (BAG):

      property marker

      on DropSprite(me, aLoc)
      vSprite = sprite(me.spriteNum)
      vRect = vSprite.rect

      if aLoc.inside(vRect) then
      go marker
      end if
      end DropSprite

      on getPropertyDescriptionList(me)
      vPropertyList = [:]

      vPropertyList[ \
      #marker] = [ \
      #comment: "Marker to jump to when DropSprite is called", \
      #format: #marker, \
      #default: marker(1)]

      return vPropertyList
      end getPropertyDescriptionList





      Any help would be greatly appreciated! Thank you.
        • 1. Re: Drag & Drop Game - I'm stuck!
          Level 7
          You've left out the beginSprite portion of one of the handlers so I created
          what I thought you might be using there.

          Instead of declaring a marker for a correct sprite in the bag sprite, I've
          changed it to the draggable sprites so each has a designation of correct or
          incorrect. This way you have the choice of making more than one "correct"
          if you're using many sprites. Now, the bag checks first to see if a dropped
          sprite is within itself then checks the type of sprite to determine what the
          target marker is. You could add a property for correct and incorrect to
          determine the target marker rather than hard coding it like I did. But
          that's left as an exersize for the student ;)

          -->> I HAVE THIS SCRIPT ON MY TARGET AREA (BAG):

          on DropSprite(me, aLoc, spriteType)
          vSprite = sprite(me.spriteNum)
          vRect = vSprite.rect

          if aLoc.inside(vRect) then
          if spriteType = #correct then
          go marker ("correct")
          else
          go marker ("incorrect")
          end if
          end if
          end DropSprite

          -->> I HAVE THIS SCRIPT ON MY DRAGGABLE ITEM:
          property pSprite, pOffset, pStartLoc, pSpriteType

          on BeginSprite me
          pSprite = sprite (me.spriteNum)
          pOffset = 0
          pStartLoc = 0

          (the actorList).add (me)
          end

          on endSprite(me)
          (the actorList).deleteOne(me)
          end endSprite

          on mouseDown me
          pOffset = pSprite.loc - the mouseLoc
          pStartLoc = pSprite.loc
          (the actorList).append(me)
          end

          on stepFrame(me)
          if the mouseDown then
          pSprite.loc = pOffset + the mouseLoc

          else
          sendAllSprites(#DropSprite, the mouseLoc, pSpriteType)
          pSprite.loc = pStartLoc
          (the actorList).deleteOne(me)
          end if
          end stepFrame

          on getPropertyDescriptionList(me)
          vPropertyList = [:]

          vPropertyList [\
          #pSpriteType] = [\
          #comment: "Correct or incorrect",\
          #format: #symbol,\
          #range: [#correct, #incorrect],\
          #default: #incorrect]

          return vPropertyList
          end getPropertyDescriptionList
          --
          Craig Wollman
          Lingo Specialist
          Word of Mouth Productions
          212-928-9581

          www.wordofmouthpros.com
          "Dava" <webforumsuser@macromedia.com> wrote in message
          news:eoqaqt$pd3$1@forums.macromedia.com...
          > Hello.
          >
          > I'll try and explain this as simply as I can!
          >
          > I have a drag and drop game where you have to drag one of 4 items into a
          > bag.
          > If you chose the right item and drag that into the bag, you'll jump to a
          > specific marker which says CORRECT. If you drag any of the other 3 items,
          > you'll jump to a marker that says FALSE. In other words, for each item I
          > need
          > it to jump to a different marker when you've dragged it in.
          >
          > At the moment I've managed to get it working so it jumps to the marker,
          > but it
          > jumps to the same marker which ever item you drag. I need them to be
          > different.
          >
          > >> I HAVE THIS SCRIPT ON MY DRAGGABLE ITEM:
          >
          > end beginSprite
          >
          > on endSprite(me)
          > (the actorList).deleteOne(me)
          > end endSprite
          >
          > on mouseDown me
          > pOffset = pSprite.loc - the mouseLoc
          > (the actorList).append(me)
          > end
          >
          > on stepFrame(me)
          > if the mouseDown then
          > pSprite.loc = pOffset + the mouseLoc
          >
          > else
          > sendAllSprites(#DropSprite, the mouseLoc)
          > pSprite.loc = pStartLoc
          > (the actorList).deleteOne(me)
          > end if
          > end stepFrame
          >
          >
          > >> I HAVE THIS SCRIPT ON MY TARGET AREA (BAG):
          >
          > property marker
          >
          > on DropSprite(me, aLoc)
          > vSprite = sprite(me.spriteNum)
          > vRect = vSprite.rect
          >
          > if aLoc.inside(vRect) then
          > go marker
          > end if
          > end DropSprite
          >
          > on getPropertyDescriptionList(me)
          > vPropertyList = [:]
          >
          > vPropertyList[ \
          > #marker] = [ \
          > #comment: "Marker to jump to when DropSprite is called", \
          > #format: #marker, \
          > #default: marker(1)]
          >
          > return vPropertyList
          > end getPropertyDescriptionList
          >
          >
          >
          >
          >
          > Any help would be greatly appreciated! Thank you.
          >