Struggling with picking/creating objects created from a family (Cardgame)

0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi,

    My project is a cardgame, think of Hearthstone, Yugioh, Magic etc.

    Almost all of the logic happens on the backend in different arrays. The visual parts on the screen like the gameboard, the deck of cards and the players hands (cards in hand) are intended to exist only for visualisation and Player input.

    Now, Im struggling with displaying and updating the cards in the hand of the player.

    Originally all the handcards were inside a single object as different animation frames. It worked roughly like this: When the player draws a card, I would just spawn a new Handcard object and set the animation frame to the corresponding ID of the Playerhand Array. And this worked fine for me.

    However, to reduce image memory use I would like to change my approach and instead of having all cards as frames of one single object I wanted to put them in a family, so I just have to load the cards that are actually in use at the moment.

    My problem is, I cant figure out how to properly pick or create my objects using the family, to edit their variables (like their position on the screen or to which handslot they belong etc.).

    The family is called "Handcard" and the different cards are objects named after an arbitrary ID I gave them like C001 or C017.

    If I use the create object action to create a "Handcard" (the family), I cant control which card is created it seems to be random. At least I couldnt figure out how to specify which objetc from the family should be created.

    And then I tried to create the object by name but then I cant pick the object (at least I dont know how). "Pick last created Handcard" doesnt seem to work, I guess because I didnt create the object specificly as a "Handcard".

    The last Idea I had was to go through them one by one bye IID but Families dont have a overarching IID, instead the objects have unique IID's so this didnt work either.

    I hope I managed to describe my Issu clearly, if something isnt clear please ask.

    Thanks for reading and I really hope someone can help me. Thank you in advance!

  • You can't specify which object is created so you'll have to use logic like if ID=1 create object 1 etc. You can use family instance variables to assign stats to the card.

  • The problem is that I cant pick the object I just created to change its variables.

    There is one thing I should clarify: I dont want to hardcode each individual object/card. The game is intended to have at least 100 cards. Thats why I tried to create by name. My approach was to create by name: "C"&CardID. But then I cant seem to pick the object I just created.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you know what the last card created was by some variable to compare with the family then you can use system > pick last created 'Family'.

    edit : I just read that you tried that, so what wasn't working? It should recognise that the object is in the family

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