How do I for add sprite to array?

0 favourites
  • 5 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi.. I'm new here and I newbie too for using construct 2.

    I make a game "guess what" with using logic if the button right have pressed and then the score will add 10 point. I have a problem for short the my event game. In my game I have few button for right anwer and then i have many button too for wrong answer. I think for adding my brong button to an array? But I didn't khow for adding sprite button to array and how to call it. Can someone help me?

  • I'm afraid your description is a bit confusing.

    It would be easier if you provided the capx for your project as it stands.

    First with a single sprite, an animation speed of 0, you can then use the sprite as a bank of images you can display only once at a time.

    This way, depending on what animation frame your sprite is displaying you can set whether it is a correct answer or not with a simple condition whether the animation frame displayed is higher than a certain number or not.

  • I understand your difficult to express yourself in english while it's not your main language. By understanding it I can feel what you mean and I'll try my bet.

    You don't need an array for it, just a global variable is sufficient.

    While you create an object on the screen, it have something called Instance Variable on the left side of the screen. By default it's empty, but you can change it by adding a Boolean variable, for example, called Type. Set the default to be "false".

    I don't know if you're creating your buttons on the screen or they are permanent, so, I'll assume the first, you're creating your buttons on the screen while the game is running.

    While creating your buttons on the screen, you may use the follow event sequence;

    Question start:

    Action: Create Sprite Button 1 at X1,Y1;

    Create Button 2 at X2,Y2;

    etc;

    Now, you'll change it to:

    Create Sprite Button 1 at X1,Y1;

    Set Sprite Button "boolean" variable to "true" (or "false" depending of your wish);

    Create Sprite Button 2 at X2,Y2;

    Set Sprite Button "boolean" variable to "true" (or "false" depending of your wish);

    They are in sequence, so, you'll be able to know what button have the true answer and will be able to check if the player has pressed it, adding points to his score.

    To check it is simple:

    Conditions: Click or Touch on the object AND Object Boolean Variable is true;

    Action: Add 10 to the Score Global Variable;

    Condition: Else

    Action: Subtract 10 points (or do nothing, depending of your wish)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I understand your difficult to express yourself in english while it's not your main language. By understanding it I can feel what you mean and I'll try my bet.

    You don't need an array for it, just a global variable is sufficient.

    While you create an object on the screen, it have something called Instance Variable on the left side of the screen. By default it's empty, but you can change it by adding a Boolean variable, for example, called Type. Set the default to be "false".

    I don't know if you're creating your buttons on the screen or they are permanent, so, I'll assume the first, you're creating your buttons on the screen while the game is running.

    While creating your buttons on the screen, you may use the follow event sequence;

    Question start:

    Action: Create Sprite Button 1 at X1,Y1;

    Create Button 2 at X2,Y2;

    etc;

    Now, you'll change it to:

    Create Sprite Button 1 at X1,Y1;

    Set Sprite Button "boolean" variable to "true" (or "false" depending of your wish);

    Create Sprite Button 2 at X2,Y2;

    Set Sprite Button "boolean" variable to "true" (or "false" depending of your wish);

    They are in sequence, so, you'll be able to know what button have the true answer and will be able to check if the player has pressed it, adding points to his score.

    To check it is simple:

    Conditions: Click or Touch on the object AND Object Boolean Variable is true;

    Action: Add 10 to the Score Global Variable;

    Condition: Else

    Action: Subtract 10 points (or do nothing, depending of your wish)

    Ty for the help now i got idea. Thanks for your advice

  • I'm afraid your description is a bit confusing.

    It would be easier if you provided the capx for your project as it stands.

    First with a single sprite, an animation speed of 0, you can then use the sprite as a bank of images you can display only once at a time.

    This way, depending on what animation frame your sprite is displaying you can set whether it is a correct answer or not with a simple condition whether the animation frame displayed is higher than a certain number or not.

    i got confused too. Sorry but i got the solution now. thanks

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