(NEWBIE) Changing Images of Sprites with Array's

0 favourites
  • 6 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • Hello Guys, first of all I should say that I'm from Germany and my English is not very good. But I'll try my best, to ask in an understanding way and don't make it too hard for you to read.

    Im an absolutely Newbie, but I'm doing quite good for the amount of time that I spent to Construct 2. So, what is my Problem?

    Im trying to make my own Cardgame. I designed all the Layouts for the Menu with Photoshop and linked them to each other with the use of invisible sprites and instance variables. This is working.

    But now I'm on a very tricky point. I designed my Deck-Builder. For now, it's just very simple and I just made to little buttons, to switch between all the cards in my set. I added two Buttons, which are called "Previous" and "Next".

    So, when the User is clicking on Next, he should see the next Card in the Gallery. Same for the other button, just with an insert-effect.

    I defined an simple Array with 5 units on the x-Axis. Then, I set up the position from my Sprite to the Previewwindow from myLayout. I added more sprites to the animations of the first one I gave them an ID_Name. For example:




    I was hoping, that I could easily switch between the sprites with a global number - card_num. But this is not working for me.

    I did it this way:

    Set animations to "ID_" &Cards.at(card_num) (play from beginning)

    Set text to cards.at(card_num) < so there will also be a text, that will show the name of the chosen card.

    And now my most hated part:

    I did a Button-Event. On Clicked, this button should add 1 to my global. I used the a system-action, to make it work -> System -> "Add 1 to card_num"

    But when I click my button, the sprite is not changing my Images. I can't find a solution for this problem. Hopefully you guys can help me!

    Thank you so much,


  • Why do you need the array? Why not set animation simply to "ID_Card"&card_num ?

    I'm always telling people that many things that usually require arrays, in Construct can be done easier without them. I'm pretty sure you don't need any arrays here. You can generate all cards in advance, or simply put them on the layout in editor and set their animation names. See these examples:



    Dealing the whole deck of cards without any arrays!

    Edit: oops, forgot to mention, you will need MoveTo behavior to open these files. It's a great addon, I highly recommend installing it.

  • This is very beautiful! Thank you so much... it's not the kind of cardgame I wanna create, but I guess it's very helpful to learn more about the shuffle / draw-mechanics in general :-) The Code looks very weird! It's very hard for me, to follow the listed steps, even with the comments. But I'm very grateful - I will dive more into this and hopefully I'll get it soon. Can I ask you again for specific questions?

    Kind regards,


  • Hi 2Broke and Welcome,

    this may be what you were looking for,


    And re the hated part, is this of any help


  • Damn, this looks so logic and easy! Thank you WhosWho, you helped me a lot :-)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Glad to be of assistance to you :)

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