Newbie problem with word game

kjasminekjasmine Member, PRO Posts: 5
Hey,

Im trying to make a word game. The idea is to have for example three grey tiles and four letters and the user are supposed to drag the letters in to the boxes and if it is correct the will go to the next scene. I also want to have a button for helppicture and one for a helpletter. Right now Im trying to do the drag and drop function.

Someone has some answers?

Have a nice friday!

/Jasmine

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited November 2013
    Hi Jasmine,

    The drag bit is easy, have a rule for when pressed constrain the position x and y of the tile/letter to the mouse position x and y.

    For the dropping part, assuming you want it to automatically centre in the box you could have a rule on each box that says if collides with letter tile (add a tag to the letter actors, and the same tag for all) then store the x and y position of that box into a game attribute. On the tile/letter have a rule that says when released and colliding with box set tile/letter to the x and y position of the box, and you will have that stored in a game attribute from the above rule. Here's the example code:

    On the Letter Holder / Box:

    Rule: If collides with actor of tag type "Letter"
    Change Attribute: game.selectedLetterHolderX = self.Position.X
    Change Attribute: game.selectedLetterHolderY = self.Position.Y

    On the Tile:

    Rule: If touch is pressed
    Constrain Attribute: self.Position.X = game.Mouse.Position.X
    Constrain Attribute: self.Position.Y = game.Mouse.Position.Y

    Rule: If touch is released and collides with actor of tag type "LetterHolder"
    Change Attribute: self.Position.X = game.selectedLetterHolderX
    Change Attribute: self.Position.Y = game.selectedLetterHolderY

    That's one way of doing it.
Sign In or Register to comment.