need help with one calculation

Get help using Construct 2

Post » Fri Oct 21, 2016 9:30 am

I starting prepare capx example but im stuck on moment where i need help
explonation what i need
Image

on start we have small baloon, baloon can have maximum size (sprite with low opacity show maximum)

we have two textboxes
so we can type 'grow time' and 'decrease time'

So when we click start baloon should
-grow to his maximum size with x seconds
-pause 0.5 s
-decrease size with typed time
-and pause 0.5
end
capx
https://dl.dropboxusercontent.com/u/447 ... eTime.capx
B
25
S
8
Posts: 212
Reputation: 2,167

Post » Fri Oct 21, 2016 10:44 am

Hi @IGDev!

I can't enter your capx cause I'm on the stable version, but I'll try without it.

First, your balloon needs the Timer Behavior.
Then, you should try something like this :

Code: Select all
On start button clicked : Start ballon.Timer "growTimer", with a duration of float(growtime.text)

Every tick if ballon.Timer.Duration("growTimer") > 0 : Set ballon width (resp. height) to maximum width (resp. height) * balloon.Timer.TotalTime("growTimer") / balloon.Timer.Duration("growTimer")

On balloon.Timer("growTimer") :  Start balloon.timer "decreaseTimer" with duration of float(decreasetime.text)

Every tick if ballon.Timer.Duration("decreaseTimer") > 0 AND if width & height not inferior than minimum width and height : Set ballon width (resp. height) to maximum width (resp. height) - (maximum width (resp. height) * balloon.Timer.TotalTime("decreaseTimer") / balloon.Timer.Duration("decreaseTimer"))


When the ballon grows, you can use a simple cross multiplication based on the progression of the timer. When it decreases, since the TotalTime still grows, you must substract the result of the cross multiplication from the maximum size. Do not forget to prevent the ballon to have a width and height of 0, by setting their minimums.
Image
B
10
S
3
G
2
Posts: 78
Reputation: 1,729

Post » Fri Oct 21, 2016 11:03 am

One has to add Increase or decrease variable then using these you can do your calculation
B
249
S
39
G
15
Posts: 1,952
Reputation: 40,596

Post » Fri Oct 21, 2016 12:34 pm

thanks, can you write more about this?
Lordshiva1948 wrote:One has to add Increase or decrease variable then using these you can do your calculation
B
25
S
8
Posts: 212
Reputation: 2,167

Post » Fri Oct 21, 2016 12:38 pm

Hi, thanks im stuck on this line,

On balloon.Timer("growTimer") : Start balloon.timer "decreaseTimer" with duration of float(decreasetime.text)

really dont know how i should type this expressions
https://www.dropbox.com/s/egifw18onzxg6 ... 9.png?dl=0
Last edited by IGDev on Fri Oct 21, 2016 2:07 pm, edited 1 time in total.
B
25
S
8
Posts: 212
Reputation: 2,167

Post » Fri Oct 21, 2016 1:34 pm

IGDev at moment my health is little bad. give me little time and I will help you
B
249
S
39
G
15
Posts: 1,952
Reputation: 40,596

Post » Fri Oct 21, 2016 5:56 pm

@IGDev, the screen does not match exactly what I suggested. I'll give you a commented capx this evening to show you. ;)

EDIT : As promised, here is the capx : balloon_problem capx

I voluntarily used actions Set Width and Set Height instead of Set Size, for you to read it more easily. If you have any questions about what I did, ask. ;)
Image
B
10
S
3
G
2
Posts: 78
Reputation: 1,729

Post » Fri Oct 21, 2016 8:16 pm

@Bro7hers oh man thats great and dificult one more thing for end this example

grow x seconds (you add this)
pause x second before start decrease (missing)
decrease x seconds (you add this)
and pause x seconds ( missing before start over again

will be great if you add this two little things THANKS!
B
25
S
8
Posts: 212
Reputation: 2,167

Post » Fri Oct 21, 2016 9:09 pm

Your welcome, but I'm not sure to understand the effects wanted with these pauses. You want the balloon to decrease before it reaches its maximum size? I think you can try something on your own with my capx. I gave you the main mechanic, but testing is always the better to really understand. :)
Image
B
10
S
3
G
2
Posts: 78
Reputation: 1,729

Post » Fri Oct 21, 2016 9:43 pm

@Bro7hers You are right, need to know how it works, you make lot of work THANKS :)
B
25
S
8
Posts: 212
Reputation: 2,167

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, namaewayukidesu, Yahoo [Bot] and 4 guests