Cheap way to do array of buttons?

Get help using Construct 2

Post » Thu Apr 13, 2017 8:54 pm




Wow, you sir are a legend, so good. Thanks
B
8
Posts: 21
Reputation: 342

Post » Thu Apr 13, 2017 9:51 pm

The 'Pick overlapping point' picks the 'color' that is under the touch. For this 'color' we set the state touched to true. This is a change. Because in the previous line we set 'touched' for all 'color' to false.

Since it is a new pick, the expression color.UID returns the UID for that newly picked color.
Now we compare that color.UID to previousTouched.

previousTouched is set to the UID of the previous picked 'color', it is set before the color.UID is changed due the new pick, so it is the UID for 'color' that was picked in the previous tick.

If we compare them, we compare previous against current. Read is as ...

EVENT 5
If there is a color picked in the previous tick (is there one 'color' with 'touched' = true) , set previousTouched to color.UID. If the condtion is true, the picklist contains that one 'color' with boolean 'touched' = true. And the action has a picked 'color' to run on.

If the condtion is not true (there is no 'color' with 'touched' = true), then the default (- 9) is just unchanged. Because the actions in event 5 have no 'color' in the picklist, if there is not one 'color' with 'touched' = true. The picklist will be empty. And the action has totaly no picked 'color' to run on.

So, if there is a touched 'color' then previousTouched = color.UID, if there is no touched 'color' then previousTouched = -9.
Since at this point no boolean 'touched' changed yet, color.UID is also = UID for the 'color' that is picked in the previous tick.

EVENT 6
Sets the boolean 'touched' for all 'color' = false.

EVENT 7
Sets the boolean 'touched' according the new situation.
Since touch changed position, it is possible that a different 'color' will be picked.
'Pick overlapping point' looks what is under the touch. And sets the boolean 'touched' for the picked color to true. We need this boolean in the next tick, it will be the previous in the next tick.
As this point we again have 1 'color' with the boolean 'touched' set to true, after we have we set the boolean for all 'color' to false in the previous event(7). That is just an easy a reliable sorta kinda 'else.

In stead of
... If under touch .. set to true ... else .. set to false (that is so difficult to do)
i do
... blindly set them all false .. set the only one under touch to true (so gd easy logic)

Now we need to know if it is the same 'color' as in the previous tick, or is it a new 'color' ?

EVENT 8
So event 8 compares the UID of the PICKED color (color.UID) to UID of the color from before that pick in event 7 changed the situation.
We only need the action to run if there is a new color choosen compared to the previous tick.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Apr 13, 2017 11:17 pm

@99Instances2Go wow Amazing explanation thank you for your patient and for all your help you are awesome men, but it's me that I don't get it just one part because I think will be easier if I give an example for what I understand till now so you can see where I'm wrong:

let's say my first pick will be instance color 1 and we start from line 7 to make it easier

-line 7: I overlap color 1 so we set it to touched and this is the one in the pick list
-line 8: checks color 1 against "previousTouched" from line 5 wich at this moment its still -9 so is not the same then runs the code

Next thick:

line 5: we have still picked color 1 on the list so we set "previousTouched" to color 1
line 6: set all touched to false so "previousTouched" becomes = -9 again

line 7: I overlap color 2 now so we set it to touched and this is the one in the pick list
line 8: checks color 2 against "previousTouched" from line 5 wich at this moment its still -9 because on line 6 we reset it -9 as all touched becomes false

etc.......all the thicks will be the same

That's why I'm confused when on line 8 we compare against line 5 "previousTouched" because it looks for me like its always -9 before reach line 7, because it meets with line 6 before 7 and set them to -9 always

I know I'm wrong with something but I don't know were
B
38
S
22
G
62
Posts: 233
Reputation: 35,054

Post » Fri Apr 14, 2017 7:26 am

let's say my first pick will be instance color 1 and we start from line 7 to make it easier


-line 7: I overlap color 1 so we set it to touched and this is the one in the pick list
-line 8: checks color 1 against "previousTouched" from line 5 wich at this moment its still -9 so is not the same then runs the code

Next thick:

line 5: we have still picked color 1 on the list so we set "previousTouched" to color 1
line 6: set all touched to false so "previousTouched" becomes = -9 again Nope. Only 'touched' is set to 'false'. There is totally no action that is changing 'previousTouched' to anything in line 6
So 'previousTouched' remains set to color 1

line 7: I overlap color 2 now so we set it to touched and this is the one in the pick list
line 8: checks color 2 against "previousTouched" from line 5 wich at this moment its still -9 because on line 6 we reset it -9 as all touched becomes false Nope, 'previousTouched' remains set to color 1

etc.......all the thicks will be the same

That's why I'm confused when on line 8 we compare against line 5 "previousTouched" because it looks for me like its always -9 before reach line 7, because it meets with line 6 before 7 and set them to -9 always

I know I'm wrong with something but I don't know were
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Apr 14, 2017 8:36 am

@99Instances2Go I finally managed to implement this and it's working great, the lerp was going to be my next mission but you have handled that too. I have one query that I can't seem to figure out. I changed the RGB effect to HSL and after doing so the colors only change while the picker is over the color, otherwise it will abandon the color change mid-transition. I solved it (temporarily?) by disabling the move picker off layout event. What am I missing here?
B
8
Posts: 21
Reputation: 342

Post » Fri Apr 14, 2017 8:38 am

@oosyrag haha that's a worthy interruption, thanks. I'm hoping to have a demo up in about a week,
B
8
Posts: 21
Reputation: 342

Post » Fri Apr 14, 2017 10:53 am

You can use HSL. & Since your colors have all kinda the same brightness & luminosity, you only have to lerp the Hue.
But, i have no idea how you gonna end up with the same color as the background colors, that way.

The Hue is more like a clock.. Its units are rather in degrees on a color wheel. Should be.

A hue of zero degrees color should be red. 60 degrees should be yellow. 120 should be green. 240 should be blue. 360 should be red again. This also means that if you change the hue from 240 to zero, you see the color change from blue, over green, over yellow, till it is red.

But, we talk about an effect. An effect is changing the existing sprite (its existing color).
So, the color is actually 'the existing hue of the sprite, as made in the sprite editor' + 'the hue in effect'.

Again, should be.

This would mean that ...
If the sprite = blue
... the resulting color = hue for blue + hue in effect ..
.. or
the resulting color for hue for blue + 360 should be blue again.

And that is not happening at all, test it and you will see.
If you start with a blue sprite, and set the hue in the effect to 360, the resulting color is close to black.
And that should for sure not happen, because that comes down to a change in the luminosity.

Besides that. I dont understand the units for the hue in the effect.
If you start with a red sprite, a hue of 30 gives already green as the resulting color.
That should be (if hue is in degree units as used every where else, virtual everywhere else) red sprite + 120 as value in the effect.

Now lets assume that 360 is scaled to 100. Or 100% = 360 degrees. This is done a lot in the effects.
Then, starting from red ... green = a 33 hue in the effect. Okay, that seems to hold.
But, then staring from red, a hue of 100 should give red again. Again. This is not happening.
So the last 20 % of the range 0 to 100 % for the hue value is completely useless.

I have the problem with luminosity. It is an effect. So the resulting luminosity = the existing luminosity *+-%/ the luminosity value in the effect. I just did not figure out this operator (*+-%/) yet. I have really no idea !
So excuse me for not being a big help.

Nevertheless, lets do it.
https://www.dropbox.com/s/0mybm78ildju2 ... .capx?dl=0

Same thing, but now with HSL.
Notice 3 things.

1/ the starting values for the 'dude' can not be 0,0,0. They must kinda match red. The color we start the 'dude' with.
2 / I never get those nice pastel colors matched. Because i dont understand the luminosity values. Mayby you can. My understanding of color wheels dont match at all with this concept for luminosity.
3 / purple is out of the box, because its matching hue value is bigger then 80. So its somewhere in the complete useless range hue = 80 - 100 %

Hope this helped you, it did not help me, because i had to dive into this HSL effect that hate from my toes up into the unlimited sky.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Apr 14, 2017 11:33 am

@99Instances2Go I have matched them all except for the purple (you're right about the last 20% being totally useless) using just the hue value but I'm sure I can get around this with a bit of fiddling.

My issue now being you have to hold the click for a second in order for the full color to "develop", what would you suggest to force it to always finish the transition? Is it as simple as putting a wait in there before re-positioning the picker?

Thanks for braving the HSL landscape for me, I can see why it wouldn't be your favorite! Adjust Hue by @rojo seemed to work great but it causes some transparency issues on iOS.
B
8
Posts: 21
Reputation: 342

Post » Fri Apr 14, 2017 12:02 pm

Dont use lerp, set the color instantly. The lerp takes time.

Or
set the timer faster. Set it to 0.5 seconds, if you dont wanna wait 1 second.
But ...
Then the lerp is then ... lerp(dude.l,color.l, dude.Timer.CurrentTime("color") / (1/0.5)) <-- 0.5 stands for the timer time

Or
If you want it to only be instantly on the first touch.
Dont start the timer when previousTouched = -9
Set the values instantly when previousTouched = -9

Still, is using replace color, as i did in the first attempt, not a lot smoother ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Apr 14, 2017 12:41 pm

@99instances2Go, it was a lot smoother I was just having some troubles with the shadow color on the sprite, maybe I should revisit this as I'm not very familiar with the replace color effect.

The transition setup would be ideal, it's the fact that it abandons the transition halfway through unless the mouse is still down. I would like it to always arrive at the destination color. I already fixed this by keeping the picker in place, just worried that you had it moving out of view for a reason.

I could definitely get by with the instant solution though, damn you're thorough :D
Last edited by shaundraws on Fri Apr 14, 2017 12:51 pm, edited 1 time in total.
B
8
Posts: 21
Reputation: 342

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: tarek2 and 19 guests