Drag and drop game

0 favourites
  • 11 posts
From the Asset Store
Now you can drop everything in your game with sound :)
  • Hi,

    This is my very first attempt at making a game in Construct 2, also I'm a newbie in programming. I'm trying to make a very simple Drag and drop game. There are 10 objects on the screen, which the players have to match to their 10 descriptions. (So object 1 matches description 1 etc).

    What I can do so far easily is to calculate score, so if the player matches 1 object correctly, he gets 1 point, and if he does so incorrectly, he loses 1 point. When an object is dragged, correctly or incorrectly, it is destroyed because I don't want them to be dragged again.

    All this works fine, only thing I can't work out is, how to code that once all the 10 items are dragged (correct or not), we reach the end of the game, and I can display a Good job screen.(I'm not using time here). Is there a way to do this?

    Thanks for your help.

  • Can someone please help? My problem with teh game is that since there are 10 different items, I can't apply instance variables...I need to put in an action which says something like once ALL the 10 objects are dragged, display the Good job screen.

    Thanks for looking.

  • You could use a family if you want to use instance variables.

    I guess you could also do it with a normal global variable. Everytime you match/mismatch a pair add 1 to that variable, and when it reaches 10 make the final screen appear. Just be sure to reset the variable at start of layout if you have more than one level.

  • Hi Xavier,

    Thanks for your reply. I've tried Global variable, but because my events go like this, I can't have a single global variable:

    A is on collison with Description A, add 1 to global variable

    A is dropped (not in collison with Description A), subtract 1 from global variable

    But when I do this, since there is no set number in the end, as I don't know if the players will get 5/10 or 9/10 or 1/10, I don't know what to set the final Global varioable value to be.

    What I wanted to do ideally was to create something like this:

    Object A in collion with Description A, add 1 to Global variable

    ELSE

    subtract 1 from global variable

    But I can't do this since there is no else activated in the Actions tab....

    sorry does this make sense? I would like to add my file but I can't seem to do that here?

    Thanks

  • Well, then I guess you could use 2 variables, one that takes care of the score, and the other one that takes care of the number of objects. So everytime a match/mistmatch happens, you always add 1 to one variable, and also you add or substract 1 to the score variable. At the end you will have one variable that will always be 10 which will trigger the "final screen" and another one that will be 1-10 that can be used to display the score.

    "Else" is not on the actions, you have to right-click on the condition, select the Add option and finally "Add Else".

    You can post a .capx of your project, just upload it to dropbox public folder like everyone else.

  • object.Count will tell you how many of the objects there are. When they're all destroyed it will be 0.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I just posted an example drag-n-drop matching game in the arcade, with source. Although by default it checks to see if all of the objects are matched, I updated it to also include the option to end the game based on the number of tries. Look at the comments to see what to toggle disabled to switch the end of game test.

    Drag-n-drop-matching-game

    If you have any questions, just ask.

  • Thanks Xavier, ramones and Kittiwan, this was very helpful. I'll try these suggestions tomorrow and hopefully my game should work fine.

    Thanks very much Kittiewan, for the game and source :)

  • Hi Kittiewan,

    I've looked at your game's code, and it works very well! This might seem like a stupid question, but how/where in the events list does the title know to match up to it's picture? I mean since there are 10 pictures and 10 titles, and you have set Matched to true, but I can't see where you say that the cat's picture matches the title Cat...

    Thanks for your help again

  • Glad to help.

    Inside the draggableText drop event, after the check to see if ObjectImage is overlapping draggableText, there are two more subevents to see if draggableText.Text does or does not = an instance variable created on ObjectImage called Description. For this to work, when you create each instance of the ObjectImage, you have to set its description to the same as the matching text.

  • Oh! I see it now, thanks that makes sense! I'm going to try this now,Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)