Let me know if this is possible

0 favourites
  • 9 posts
From the Asset Store
Who wants to be a Millionaire Clone. An educational coding source
  • I'm trying to make a booster pack for a card game. I need to make it to where the game remembers what I pulled. I was trying to have it to where all the objects are in a family that has the instance variable of (Owned), and when one of them spawn they get +1 on that variable... but then I realized that as soon as I go to a different layout the variable goes away as it's a different copy of the sprite. Is there a way to do this easily, or am I going to have to do a ton of Global variables and do a on spawn event for literally every single card in the game to increase that variable by 1?

  • There are a few ways to do this. Most common method is to use an array or a dictionary to store the data about cards.

    You can also set card sprites as Global, then they will be transferred to a new layout. But be very careful not to duplicate them. If you have 10 cards on one layout and 20 cards on another, you can end up with 30 cards!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There are a few ways to do this. Most common method is to use an array or a dictionary to store the data about cards.

    You can also set card sprites as Global, then they will be transferred to a new layout. But be very careful not to duplicate them. If you have 10 cards on one layout and 20 cards on another, you can end up with 30 cards!

    I didn't realize that the location would be changed on every layout if I set them to global, so I guess I'll ask if there is any good tutorials on how to do an array or dictionary for this.

  • There are a few ways to do this. Most common method is to use an array or a dictionary to store the data about cards.

    You can also set card sprites as Global, then they will be transferred to a new layout. But be very careful not to duplicate them. If you have 10 cards on one layout and 20 cards on another, you can end up with 30 cards!

    Or more particularly, how do I do an array or dictionary without it being like 500 events long?

  • Or more particularly, how do I do an array or dictionary without it being like 500 events long

    Depends on what do you need it for.

    There are plenty of tutorials and official examples in C3, for instance:

    editor.construct.net

  • > Or more particularly, how do I do an array or dictionary without it being like 500 events long

    Depends on what do you need it for.

    There are plenty of tutorials and official examples in C3, for instance:

    https://editor.construct.net/#open=level-selection

    So yes, I'm going to have to do on each individual card spawn, change some variable, so it's going to be like 500 events.

    Also, love how the clear button in their own example thing doesn't even work.

  • So yes, I'm going to have to do on each individual card spawn, change some variable, so it's going to be like 500 events.

    Why do you think it will be 500 events? Do you have each card as a separate object? Even then you can combine them into a family and use a single event:

    Cards On Created: Array push back value Cards.ID

    or something like that.

    However, if you are planning to use the array to store cards, then it should be the other way around - you create cards from the array:

    Array For Each X : Create Card; Card set ID to Array.curValue

  • > So yes, I'm going to have to do on each individual card spawn, change some variable, so it's going to be like 500 events.

    Why do you think it will be 500 events? Do you have each card as a separate object? Even then you can combine them into a family and use a single event:

    Cards On Created: Array push back value Cards.ID

    or something like that.

    However, if you are planning to use the array to store cards, then it should be the other way around - you create cards from the array:

    Array For Each X : Create Card; Card set ID to Array.curValue

    ...well like, I'm very clearly asking how to do this as I don't know how. I wasn't sure how to do it to where it would affect the one item it applies to in a family as apposed to having to do it one sprite at a time. Like yeah, I wanna do it to when something in the card family spawns in the pack opening page that one thing will permanently tick up how many copies I own. I was trying to do it via family instance variables then I realized it wouldn't work. That's how I got here.

    (basically I've never used an array so I have no idea what I'm doing and the videos I looked at didn't help either, same goes for a dictionary)

  • > So yes, I'm going to have to do on each individual card spawn, change some variable, so it's going to be like 500 events.

    Why do you think it will be 500 events? Do you have each card as a separate object? Even then you can combine them into a family and use a single event:

    Cards On Created: Array push back value Cards.ID

    or something like that.

    However, if you are planning to use the array to store cards, then it should be the other way around - you create cards from the array:

    Array For Each X : Create Card; Card set ID to Array.curValue

    And I have now as of 2 minutes ago, with absolutely 0 tutorials or guides, have taught myself how to use the dictionary to do this since your comment about arrays gave me an idea. God I love the ease of use with this engine sometimes.

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