Ambiera ForumDiscussions, Help and Support. |
|
[ 1 2 ] Page 1 of 2 |
|
|||||
|
I'm trying to create a count down timer in CopperCube where in each level the player has a particular time e.g 10minutes to finish a level and if the player does not finish the level before the set time, game over and also the timer would be shown to the player as a 2D overlay. I'm trying to create the countdown timer in CopperCube but I can't seem to get it. |
||||
|
I probably make action for this soon (because i need this also) But you can just declare variable for example CountdownTimer=-1 To start it set value to CountdownTimer Now on every X ms do something.. If CountdownTimer !=-1 substract value.. If it reaches to 0 execute action and set it -1 ( so its disabled) On overlay you can display it as $CountdownTimer$ Edit: with some math you can convert it to minutes and seconds also.. |
||||
|
Hi, or you can add a behavior to a 2d overlay:) // The following embedded xml is for the editor and describes how the behavior can be edited: Example: https://drive.google.com/file/d/... |
||||
|
Thanks @Sven and @Okeoke @Okeoke, your behavior works properly but I noticed that when the timer reaches 00:00, the action does not take place, in the behaviour you sent in the drive link, after time runs out, it should print "Time out", but it doesn't print time out, it just get stuck in the " Time: 00:00" text, I tried adding another action, which was the Hide Scene Node action to hide the 2d overlay after the time runs out but this doesn't work too. |
||||
|
Hi @dynamogames Have you tried extensively choosing the overlay node instead of "the current scene node"? Both hiding the node and changing its text works for me that way: But "the current scene node" weirdly enough actually doesn't work. |
||||
|
Ok, it's actually my bad. I just checked the js reference ccbInvokeAction(actionId, currentNode) invoke action actually has second argument - currentNode. That's why it's not working:) You can easily fix it by updating line 39: ccbInvokeAction(this.actionOnRunOut); to ccbInvokeAction(this.actionOnRunOut, node); |
||||
|
Thanks for the contributions okeoke, but in the js file, the code does not reach line 39 but stops at line 37, I tried creating a new line for the code "ccbInvokeAction(this.actionOnRunOut, node);" but the error still persists. |
||||
|
@okeoke thank you very much for sharing! @dynamogames, okeoke's first Google Drive example seems to contain an old version of okeoke's behavior yet giving as option but still not containing "ccbInvokeAction(this.actionOnRunOut)", here you can find a hopefully fixed version (additionally fixed small typo in behavior's name): https://www.dropbox.com/s/bw21hu... |
||||
|
THX |
||||
|
Back to this thread :-), @okeoke and @hadoken, is there any way to record the time, let's say when player is in proximity to an object and save it in a variable which can be displayed on a 2D overlay. |
||||
|
Here's how to do it without coding.... // Starts a timer when node enters the zone: On Proximity (Enters) Set Variable "TimerActive" =1 // Stops (and resets) the timer when node leaves the zone: On Proximity (Leaves) Set Variable "TimerActive" =0, Set Variable Time" =0 // Updates a 2D overlay to display current time in seconds: Every few seconds (1000ms) If Variable "TimerActive" =1 Set Variable "Time" +1 Update 2D Overlay "Time= $Time$" |
||||
|
I created a game the timer countdown and shows game over. |
||||
|
dynamogames wrote: I'm trying to create a count down timer in CopperCube where in each level the player has a particular time e.g 10minutes to finish a level and if the player does not finish the level before the set time, game over and also the timer would be shown to the player as a 2D overlay. I'm trying to create the countdown timer in CopperCube but I can't seem to get it. Is this what you trying to do? https://youtu.be/au9vPiG_r5E?si=... |
||||
|
Yes exactly Serge, but I have the countdown timer implemented, I'm just trying to find a way to get players best time on proximity to a certain object, everytime they play, this best time is recorded and shown to player so that they can try and beat it. |
||||
|
@VP thanks for the contribution |
[ 1 2 ] Page 1 of 2 |
|