How do I for add sprite to array?

Get help using Construct 2

Post » Tue Dec 13, 2016 9:04 am

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?
B
8
Posts: 20
Reputation: 342

Post » Tue Dec 13, 2016 10:27 am

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Tue Dec 13, 2016 12:13 pm

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)
Image
B
107
S
24
G
18
Posts: 1,363
Reputation: 22,774

Post » Sun Dec 18, 2016 3:08 pm

TELLES0808 wrote: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)


:D Ty for the help now i got idea. Thanks for your advice
B
8
Posts: 20
Reputation: 342

Post » Sun Dec 18, 2016 3:10 pm

Kyatric wrote: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
B
8
Posts: 20
Reputation: 342


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests