[SOLVED] need help in creating invert effect without Webgl

Get help using Construct 2

Post » Mon Aug 01, 2016 8:29 am

I am trying to make invert effect without using webgl effect
So I have 2 Sprites
1 as object & 2 as background
each has 2 animation frame, 1 is black and 2 is white
black & white colors only
if BG black then object is white
if bg is white then object is black
>> this is my layout and objects in it
>>>>>>>>>>
So What I am trying to do is
on every 3 second both opacity go down smoothly and when opacity is zero then animation frame change from 0 to 1 & 1 to 0 and opacity go up
>>>>>>>>>
for smooth opacity i used lerp
i made an extra object and every 3 second it position is y=50, & y = 300
when y = 50 adding lerp
when y = 300 subtracting lerp
>>>>>>>>
please take a look
Please do help
attached capx
Last edited by luckyrawatlucky on Fri Sep 16, 2016 6:56 am, edited 1 time in total.
Image
B
63
S
39
G
42
Posts: 630
Reputation: 30,528

Post » Mon Aug 01, 2016 1:39 pm

Invert is a toggle. It is 1 or 0. Invert or not inverted.

Since 50% inverted does not exist (yes it does in your mind, that is why your mind is so beatyfull) there is no tweening possible.

You can ofcourse dissolve from not-inverted-state to inverted-state. But even that can not force the inbetween steps to make any sense. Then again, if no inbetween step can ever make sense, we can just feed something nice to the eye. In video i would probaly go for a dissolve that blends in a linear color space, or a soft circulair wipe.

This is an example of just dissolving from one state to the other.
https://www.dropbox.com/s/n7bpvdgvario9 ... .capx?dl=0

Hope at least you have something at the way how i use a timer.
Greetings.
B
33
S
18
G
27
Posts: 2,447
Reputation: 20,358

Post » Tue Aug 02, 2016 5:22 am

No No No
I was not doing 50% invert
i was trying to down opacity 0%
or when opacity is 0% i was trying to do trick here, i was changing frame
but my math is not strong
my other big problem is
its being 1 year, i am using Construct 2 but still I did not notice most of features in C2
like time feature I have noticed this when you use this in capx.
>>>>
I know only that portion of Construct 2 which i have used in my previous game

Actually when I started Construct 2 or I have zero knowledge of C2
I have created a game in my mind and then I was moved to make it possible
and from beginning I have started searching about how to make first part of my game, then second, then third so on
i have learned everything what my game required and except that I don't know any thing in construct 2
My first game is complete now. I have not noticed other feature in construct 2 and now when i got some new ideas of games and now again a beginner in construct 2
Image
B
63
S
39
G
42
Posts: 630
Reputation: 30,528

Post » Tue Aug 02, 2016 5:29 am

99Instances2Go wrote:Invert is a toggle. It is 1 or 0. Invert or not inverted.

Since 50% inverted does not exist (yes it does in your mind, that is why your mind is so beatyfull) there is no tweening possible.

You can ofcourse dissolve from not-inverted-state to inverted-state. But even that can not force the inbetween steps to make any sense. Then again, if no inbetween step can ever make sense, we can just feed something nice to the eye. In video i would probaly go for a dissolve that blends in a linear color space, or a soft circulair wipe.

This is an example of just dissolving from one state to the other.
https://www.dropbox.com/s/n7bpvdgvario9 ... .capx?dl=0

Hope at least you have something at the way how i use a timer.
Greetings.


Thanks your example is awesome
Its being 1 hour but i did not get what you have done with background, when i am moving it in layout to out of layout its showing black and in layout its showing as white. It makes me confuse because their is no effect on that sprite but how its showing black.
and can you explain me how this lerp is working
lerp(100,0,Sprite.Timer.CurrentTime("steps")/second)

Edited
one thing more
i had take 3 seconds just for example
actually I want to stay for some time in both inverse position
It will take 10 s or 15 seconds
first 2or3 seconds to invert then let stay for 10 seconds then invert 2or3 seconds then again stay

i have found you make 2 layers you positioned object just behind them in other layout
but in my game objects are not still every second they are creating randomly and moving
so I don't think this will work in that case
or it may possible if created in same position just behind the layer I don't have any way of doing this
May be I have to remove this feature
>>>>>>>>>>>

Actually I have done this with invert effect already invert is happening
why i am doing this ?? My purpose is
I want to make game a little size in mb 5-8 mb
for that I will build apk without using Crosswalk for android
but If I use WebGl effect its doing game slow (I have tested)
If i build apk using crosswalk then my game will be 30mb
that is the reason I am doing this
>>>>>>>>>>>

I have game ideas
some are small Projects some are big Projects based on Single Tap game
Big Project is having combination features of Subway Surfer & Candy Crush ( I have in my mind)
But I don't have ability to make them possible
I am wishing to make a big project but have no ability
So I am trying little games
Image
B
63
S
39
G
42
Posts: 630
Reputation: 30,528

Post » Tue Aug 02, 2016 8:30 am

Second layer is not transparant. Guess you missed that.
Yes, i got this about the 'moving' characters. In fact i still think it is gonna be a lot easyer with animations, even if they have allready animations. That way you only have to start an animation and dissolve background layer in and out. I can do that 4 you, if you wish, make for every animation a version that dissolves to its invert state and back. (i dont charge)

About the lerp. Every lerp is the same. lerp(a,b,step). Where 'step' is just a number between 0 and 100. When 'step' = 0, the lerp returns a. (0% between a and b) When 'step' = 1(100 % between a and b) it returns b. When 'step' = 0.4 the lerp returns a value that is 40 % between a and b.

So all you need for a perfect lerp is a start value, a end value and number that counts from zero to 1 over some time.

But lerp (as all very basic things in construct) is not dt corrected. And it should be. Else 3 seconds is in fact 3 seconds on a fast device but like 6 seconds on a slow device.

Also, lerp has no 'on arrived' conditions. Its not that easy (for me) to know during run time, when it is done with its magic.

And here comes the timer behavior as a perfect soulmate. It is dt corrected. And you can do 3 major things with it.
1/ It is private. Meaning, every instance can have its personal timer.
2/ De moment you start a timer, you can read where it is at the moment by reading its expression Sprite.Timer.CurrentTime
3/ It warns us when its done using the condition 'on timer'.

So in the example i made, i start a timer (since you stated that the dissolve has to take 3 seconds) for 3 seconds. Now the expression Sprite.Timer.CurrentTime returns a number between 0 and 3. Since it goes from 0 seconds to 3 seconds.

But we need a number between 0 and 1. Not between 0 and 3. So all we do is lerp(100,0,Sprite.Timer.CurrentTime("steps")/second) to archive that.

100 = opacity 100
0 = opacity 0
"steps" is the name of the timer, you can have more timers (one that accounts for the pauzes for ecample)
Sprite.Timer.CurrentTime("steps") counts from 0 to 3 in exact 3 seconds
Sprite.Timer.CurrentTime("steps")/second counts from 0 to 1 in exact 3 seconds

Back to dissolving from non-inverted to inverted. When that is the way you want to go, then you always need a copy of the character running arround. To dissolve to and from. Gonna be kinda hell to code. Why i think animations are a much much easyer solution.
B
33
S
18
G
27
Posts: 2,447
Reputation: 20,358

Post » Tue Aug 02, 2016 8:39 am

Note:

LiteTween, a 3th party behavior, can do all the lerping one wish to do.

behavior-litetween_t70700

That way you can avoid actual lerps.
B
33
S
18
G
27
Posts: 2,447
Reputation: 20,358

Post » Tue Aug 02, 2016 9:01 am

First I will try to make
If I fail
then you can make it
Image
B
63
S
39
G
42
Posts: 630
Reputation: 30,528

Post » Wed Aug 03, 2016 9:29 am

please make it for me
I try but i stuck
>>>
I have on (1) background
and one other object it is creating on every 1 second on random x and moving top-bottom side
Image
B
63
S
39
G
42
Posts: 630
Reputation: 30,528

Post » Mon Aug 08, 2016 5:51 am

I made it
I have done it
Image
B
63
S
39
G
42
Posts: 630
Reputation: 30,528


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 15 guests