How to add score just once, and event question

Discussion and feedback on Construct 2

Post » Sat Aug 13, 2011 6:02 am



Hello, super noob in Construct2 is here


I have some problem with my game prototype



In my game, there is player and monster. When Player collide with monster, then it will add 1 to global variable "Score"

PROBLEM here is:, it always add one more score every time player collide with the monster. But actually, I want it to add just only once.




2) There is the "Panel" sprite in my game, when player overlap it, it will have message sprite pop up, telling that player should got 5 "Score"(global variable) to finish the game.

PROBLEM here is: I would like to make the message sprite appear every time player overlap with the panel. But somehow it appear just only once!




3) When the player got 5 Scores, I would like the panel sprite to display sprite message, telling player that they finish the game.

PROBLEM IS: I can't make the message to appear, even though the Score reach "5"


Thank you very much for your help.
Love Construct!




This is the .capx file with comment

http://dl.dropbox.com/u/363243/Construct_Ask/01_2011_8_Message%20and%20Score/AskConstruct.capx raindropm2011-08-13 06:04:34
B
10
S
4
G
3
Posts: 8
Reputation: 2,242

Post » Sat Aug 13, 2011 1:47 pm

1. You need to modify event2.
Create a new event, System - Trigger once while true.
Add the Collision event/condition (between player and monster) to it, as well as you add 1 to score.
It now works.
Unfortunately, you can't add the "Trigger once" as "Add another condition", that's why you have to create a new event. But this will correct your "bug".

2. The problem comes from the fade behavior.
I don't master it, but instead of making msg_needmore visible, set its opacity to 100.
Here you go, the msg_more appears again. But the fade behavior does not retrigger. (so the second time, msg_more just stays up, and does not fade again)
I guess you could handle the fading in events. (msg_needmore.opacity = msg_needmore.opacity - 1 until it's 0)

3. Once again, the fade behavior seems making trouble.
I removed it from msg_goodjob.
I also modified event4 so that it is only "System.Score is greater or equal 5".

Once my score reaches 5, msg_goodjob displays.

I guess previously the fade behavior, already had it disappeared and so, setting it to visible didn't work as its opacity was 0 anyway.
So same as 2. you should handle fading in events.

Hope it helps. Nice gfx in your project ;)
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sun Aug 14, 2011 6:28 am

Hi Kyatric, Thank you very much for your help.

Your suggestion about Trigger once condition is superb. It works! (I didn't aware of its existence until you point out)



About the fading message problem, finally I found a way to do it by chance(which is actually really simple)

When player collide with the "Panel", I then create the condition "System---> Create object"(which is the message sprite I want), instead of adjusting with visible or opacity as I did in previous time.

and it now work perfectly, also with proper fade behavior!

Try it here if you which:
Note: Catch the 3 flying object to trigger the 'Good Job' message at the panel.

http://dl.dropbox.com/u/363243/Construct_Ask/01_2011_8_Message%20and%20Score/askTutorial/index.html



P.S. For some reason, I found that sometimes some event is not properly triggered, but after I delete that event and create the new one with the same event and condition, it happened to work just fine!
(maybe a bug in Construct?)



and here, in case anyone want to look at the .capx file.


http://dl.dropbox.com/u/363243/Construct_Ask/01_2011_8_Message%20and%20Score/AskConstruct%20-%20Final.capxraindropm2011-08-14 06:36:08
B
10
S
4
G
3
Posts: 8
Reputation: 2,242

Post » Sun Aug 14, 2011 7:05 am

[QUOTE=raindropm]About the fading message problem, finally I found a way to do it by chance(which is actually really simple)

When player collide with the "Panel", I then create the condition "System---> Create object"(which is the message sprite I want), instead of adjusting with visible or opacity as I did in previous time.

and it now work perfectly, also with proper fade behavior! [/quote]

Indeed that works and work well, cool workaround.




[QUOTE=raindropm]P.S. For some reason, I found that sometimes some event is not properly triggered, but after I delete that event and create the new one with the same event and condition, it happened to work just fine!
(maybe a bug in Construct?)[/quote]

It's possible that it's a bug.
If you can reproduce the bugging events in a .capx and report it in the bug section with the informations required in this post, I'm sure Ashley will take a close look into it.



Finaly concerning your game : You have an image moving in the background in peculiar which has a green background. And it is possible to see a "low flickering" between this green background and the white background of the layout. Either change the color of the background, or make this image's background transparent for more continuity.

Keep up the good work.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sun Aug 14, 2011 5:29 pm

Thank you Kyatric for the tip about bug report and moving background.   


By the way, I would like to ask about my new problem, that I still can't find the solution after several hours of trial and error.


Situation is, I would like to display the sprite that will disappear, and change to next one when user press any key. You know, like the page of tutorial that user read before they play the game, page by page.



It sound very simple, but I can't find a way to do it right. Would you mind enlighten me?


B
10
S
4
G
3
Posts: 8
Reputation: 2,242

Post » Sun Aug 14, 2011 6:28 pm

It depend, you have several ways of doing.
Let's take this way were the tutSprite is made of 3 frames (the actual 3 images you're depicting). They are all part of the same sprite tutSprite.

Make also a global variable "isTut" a number.

We will test "isTut" to check if you are in the tutorial or not during the execution of our app.

Event - System Compare global variable - "isTut" = 1
..Sub Event - Keyboard - On any key pressed
Other condition of this subevent^ - tutSprite - Compare animation frame - Frame is equal 1
....Action tutSprite - Set animation frame to 2

..Sub Event - Keyboard - On any key pressed
Other condition of this subevent^ - tutSprite - Compare animation frame - Frame is equal 2
....Action tutSprite - Set animation frame to 3

..Sub Event - Keyboard - On any key pressed
Other condition of this subevent^ - tutSprite - Compare animation frame - Frame is equal 3
....Action System - set global variable "isTut" to 0
....Action hide tutSprite, or destroy it, or whatever...

When you make tutSprite appear, and display its frame 1, remember to set "isTut" to 1 to indicate "Tutorial is on".


It is a way of doing, but not the only one.
In the end, it all depends on the specifics of your project, and the effect you want to apply.Kyatric2011-08-14 18:29:13
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sun Aug 14, 2011 7:20 pm

hey raindrop,

groups seem a serious solution for a tutorial of this kind. i would take 3 global variables in your case...1 for curTut, 1 for curTutSprite and 1 for curTutTxt.

everytime the user presses a key u increase the values and set the curTutTxt as u wish. also u set a group active. inside the group u check the 3 values, change the view and set the group inactive after the text and sprite has changed according to the state of the variables.

i hope u understand what i mean.
B
15
S
3
G
5
Posts: 396
Reputation: 4,977

Post » Mon Aug 15, 2011 4:35 pm

Hi, big thanks for both Kyatric and xeed!

but look like my knowledge in Construct is still at very early stage, thus I have a hard time understanding the the suggestion concept, and it sound too complex for my need.

Though eventually(after I try again), I found the way to do it with simple event. I will upload my game soon so anyone can test it.

Thank you again!
B
10
S
4
G
3
Posts: 8
Reputation: 2,242


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests