How do I adjust one side of a square object independently?

Get help using Construct 2

Post » Wed Sep 14, 2016 5:06 am

Unconnected wrote:I have a small 50 x 50 box (Scaled down) and when it is tapped it's position should stay the same and it should adjust in size to fit the Viewport, or seemingly do so. When the player is done the box should adjust back to it's original size and position. I only know how to move boxes and adjust width equally on both sided as well as height. I am unaware of how to adjust each side of the square according to it's potion within the Viewport. I was going to use Lerp for this, but I just don't know what to use for the box's edge or points. I am aware of Viewport Top, Left, Right, Bottom.

The box is just a solid color.
TragusInfantigoRx


That sounds me a lot!
Last edited by jon albert on Thu Sep 15, 2016 8:32 am, edited 1 time in total.
B
2
Posts: 2
Reputation: 154

Post » Wed Sep 14, 2016 5:52 am

@Unconnected I believe what you are doing is correct. :D

@99instances2go Isn't what you suggested just moving it at a constant speed? and therefore defeating the smoothness that lerp is typically used for? I mean.. what you said is useful, too. but when people around here ask for lerp, I usually assume they're looking for the smoothy version.

EDIT: Found this: https://www.scirra.com/blog/ashley/17/u ... delta-time
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Wed Sep 14, 2016 9:01 am

Your assuming is as good as mine.
I assume that poeple who ask how lerp works, ask how lerp works.

Lerp, when used with a liniair lerpfactor, wil indeed move at a liniar speed. So yes, you are right.
But, lerpfactor can as well be sqrt(abs(counter – 1)) ... where 'counter' goes from 0 to 1

Lets split things up. Lerp can (indeed) in two ways.

Method 1.. lerp(StaticStart,StaticEnd,DynamicFactor)
Method 2.. lerp(DynamicStart,DynamicEnd,StaticFactor)

Method 1 is (in my opion) the base-lerp, the base to learn.
Awesome to do grid movements, by instance. Base means also that it has no 'side effects'. It works as intented. And it is very easy to use.

Method 2 is (in my opion) a version that brings problems that have to be countered. Yet, you will have to use it when Start or/and End has a dynamical character. Not because of the smooting. In my opion that is mis-use. And yes it smooths, but more by accident, than intended. But you will have to take care of the problems.

Dynamical character ? When lerping a moving sprite to a moving sprite.
(In the above given situation Start and End are not dynamical)

What problems you will meet ? (you suggest to use this method, but dont tell about the problems)

Well,

The lerp will never ever arrive to its endpoint. Causing all sort of problems, that fill the forums. When lerping a camera, the camera will start shaking when the lerp is close to its end.

When close to the End, the value returned by the lerp will change in very very small amounts. Since positions and angles are always 'calculated values', this will result in randominess on sub pixel level. You see shaky sprites.

Most people use 'lerp' in a 'every tick' event. But since this lerp never arrives, and since the calculations get slighty heavyer, this lerp will just run every tick and it will eat noticable CPU.

That are my 10 cents, dont know the exchange rate.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Sep 15, 2016 12:41 am

Well said. I almost completely agree with you. But agreeing doesn't give us anything new to talk about.. so...

Well.. he said he had worked around the ONE problem (you kinda gave it a few labels, but it's still the same problem) that is caused by that. and it really isn't very hard to work around, so I didn't mention it. but yes, it does come with that problem.

I don't think either use is more proper than the other without being specific as to what the intended result is. In my mind, using lerp the way you suggested seems extraneous when there's so many built in ways to have things move or change size at a constant rate, which, I think, is why most people here in C2 land are using it for the smootherism.

I mean.. obviously the smoothing is not by accident.. tons of games and applications (big and small) use it that way.

Using it 'every tick' outside of ticks where you actually need it is obviously a whole other issue and would apply to either method..

That's only 2 cents from me. That's all I've got to spare (the exchange rate is not great...)
B
88
S
43
G
71
Posts: 601
Reputation: 43,669

Post » Thu Sep 22, 2016 8:13 pm

viewtopic.php?f=147&t=182175

@spacedoubt, you see what i mean ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Previous

Return to How do I....?

Who is online

Users browsing this forum: NN81 and 2 guests