[SOLVED]Play Die Repeat

Get help using Construct 2

Post » Mon Oct 31, 2016 12:16 pm

I'm creating a mobile game now. It uses a "Touch" plugin and 2sprites (each has 5 frames for animation).


Every 2seconds, i set the animation frame to random(0,5). If they have the same frame then player touch these sprites to obtain 1 score and then continues to touch and touch again until the player touch a wrong sprite and he loses.

My question is, how to do if the player is not touching any sprite for the 2seconds then its GameOver for the player. It's like if you do not do anything then you lose but if you touch sprite and it's correct then you can play the game.

(I want to force the player to immediately touch the sprites in 2seconds, if they do not respond, they lose and they have to repeat the game again but if they respond then you can play the game)

PLEASE HELP!
Last edited by jance0405 on Fri Nov 04, 2016 3:40 am, edited 1 time in total.
B
30
S
12
G
4
Posts: 67
Reputation: 4,250

Post » Mon Oct 31, 2016 2:17 pm

you can use timer behavior..

timerPlay.capx
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Mon Oct 31, 2016 2:53 pm

This is how i did it --

Global Variable Timer.capx
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

Post » Wed Nov 02, 2016 5:51 am

Message: jance0405 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
jeffige wrote:This is how i did it --

https://www.dropbox.com/s/50xculga24uwgu5/Play_Die_Repeat.capx?dl=0/ Global Variable Timer.capx



Thank you korbaach and jeffige for the effort in doing a capx.
I really like what jeffige did, It almost what i am looking for a solution to my problem but as i said i have 2 sprites with 5 frames each, These frames changes randomly every 2 seconds.

Sir jeffige, You set the Timer >= to 2, if its true, then GameOver for the player and the player needs to restart the game again. But when the player touches the sprite you set it to 0 so that the action you gave to Timer will not trigger and the player continue to play the game.

But as i said, i have 2 sprites with 5 frames each. "Every 2 seconds" i set their animation frame to random(0,5). When the player touches these sprites i want the "Timer" set to what currently the seconds of the animation frame.

HOW CAN I DO THAT?

Please help, this is the last condition i want to implement to my game.
B
30
S
12
G
4
Posts: 67
Reputation: 4,250

Post » Wed Nov 02, 2016 7:43 am

Looks to me like you should assign a Variable for the timer. For example TIME_DESTROY

On any Touch start && | Set TIME_DESTROY to 2
is touching SPRITE

Every tick | Subtract 1*dt from TIME_DESTROY

TIME_DESTROY = 0 | Set GAME_OVER to 1

Also, you should select frames like: choose(0,1,2,3,4) remember that the first frame is always 0.
random(0, 5) will at one point be greater than 4.5 which if rounded up will garner 5. I don't know what frame will show if that case; possibly frame 0 or frame 4.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Wed Nov 02, 2016 10:40 am

jance0405 wrote:
jeffige wrote:This is how i did it --

https://www.dropbox.com/s/50xculga24uwg ... capx?dl=0/ Global Variable Timer.capx



Thank you korbaach and jeffige for the effort in doing a capx.
I really like what jeffige did, It almost what i am looking for a solution to my problem but as i said i have 2 sprites with 5 frames each, These frames changes randomly every 2 seconds.

Sir jeffige, You set the Timer >= to 2, if its true, then GameOver for the player and the player needs to restart the game again. But when the player touches the sprite you set it to 0 so that the action you gave to Timer will not trigger and the player continue to play the game.

But as i said, i have 2 sprites with 5 frames each. "Every 2 seconds" i set their animation frame to random(0,5). When the player touches these sprites i want the "Timer" set to what currently the seconds of the animation frame.

HOW CAN I DO THAT?

Please help, this is the last condition i want to implement to my game.



Your request is super confusing.
In order for it to make more sense, you should take every informations/capx you've already been provided and make a version of your game that is close to what you are looking for. And do provide your updated capx in order for others to be able to investigate easier what you are asking and what is going wrong.

In the absolute, you can set a numeric variable value to be equal to Sprite.animationframe; this will assign the number of the currently displayed animation frame as value of your variable. It sounds like this is what you are asking for ?

You speak of a timer, but did you implement it like in one of the provided capx ? Using a variable ? Using a timer ?
This is all confusing.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
296
S
119
G
96
Posts: 7,332
Reputation: 71,306

Post » Fri Nov 04, 2016 3:29 am

Hello, thank you very much to sir jeffige. i already fixed and find a solution to my problem. I used jeffige "Global Variable Timer" on my capx, i just did some changes to meet what i wanted.

Again thank you jeffige
B
30
S
12
G
4
Posts: 67
Reputation: 4,250


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests