How do I check an overlapping object, if not self.instance

0 favourites
  • 11 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • For a sorting game, I place a number of TARGET-cards in the layout.

    ( instances of the same sprite-object, with different "CardFaceFrame" values, but with the identical Frames.

    The CardFaceFrame value indicates the CardFaceFrame-number of the object that must be placed on top of it)

    Next to these, I place an identical number of Cards, (shuffled), with the corresponding CardFaceFrames showing.

    These Cards have drag and drop behavior.

    When a Card is dragged over TARGET, I want to do three things:

    1. If no other Card ( instance of the same object) is there, the Card must snap to the TargetCard.

    2. The value of the CardFaceFrame must be written to an array: CardsPlaced, at the place of the TargetCard. (fixed that)

    3. if the array CardsPlaced is filled correctly ( 0,1,2,3 etc.) goto next level

    If there is already a Card Instance on the target, it must not be dropped.

    I cannot figure out how to check if there is already a card placed.

    Any suggestions?

  • Here you go: ... .capx?dl=0

    I added an instance variable CardUID and made a few other changes.

    See my comments in the event sheet.

    I don't think you need arrays in this game.

    Arrays in C2 are overrated <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Here is a comment I made some time ago (it's about a similar game concept as yours):


  • Wow! Thanks dop2000!

    i am very curious to see what you did

    There is one small problem... My Construct 2 cannot unzip the capx file.

    Am I missing something ..?

  • Wow! Thanks dop2000!

    i am very curious to see what you did

    There is one small problem... My Construct 2 cannot unzip the capx file.

    Am I missing something ..?

    You need to say why you can't open the .capx.

    Do you get an error message? If so, what is the message?

    This version was created in a newer version of C2 than yours but updating to the latest beta (soon to be stable, probably) will fix that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Error: Construct cannot unzip capx

  • koops

    Ok, try this one: ... .capx?dl=0

    If it still doesn't work, rename the file to .ZIP, manually unzip it to an empty folder, and then open .caproj file in Construct 2.

  • Thanks.

    Unfortunately Construct still doesn't open it.

    I downloaded Construct 2 r249,

    still the errormessage; Unable to open .... for unzipping

    Also tried renaming to zip, windows'reply: the compressed folder is invalid

    I hope we can solve this, am am very curious to learn about the siolution you added.

  • Have downloaded the .capx from dop2000 and can verify there is nothing wrong with the file, which just leaves a problem on your system.

    Something is affecting the file either whilst downloading, or after downloading.

    Do you have have problems when launching C2 and opening a template/example?

  • Thnaks!

    I could figure out from an error that I needed to use release r249.

    Now it works like a charm.

    Very interesting to learn how you solved the issue without the array.

  • You don't need an array because you already have CardFaceFrame instance variable on both CardObj and CardTargetObj.

    And there is CardUID that links instance of CardObj with instance of CardTargetObj.

    (I don't remember if I added CardUID or if you had it already?)

    All you need to do is to check if CardObj.CardFaceFrame is equal to CardTargetObj.CardFaceFrame for each pair.*

    If not equal, "win" boolean variable is set to 0.

    If all 6 cards are correct, "win" remains 1, and it means that the level is completed.

    By the way, I'm still on release 246

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