How do I Hold an object position inside another object?

Get help using Construct 2

Post » Sun Sep 24, 2017 7:34 pm

Since the Slider Bar object has a very basic and non-customizable look, I made one myself, with two sprites: the "line" (slid_line), and the "button" (slid_btn).

My slid_line is pinned to a popup that goes in and out of the screen (with LiteTween behavior) as I press a button.
I made the slid_btn always stay inside the slid_line using: slid_btn > Set X to > clamp(self.X,slid_line.X,slid_line.X+slid_line.Width).

So when the popup moves, the slid_line moves too because it's pinned to the popup. The popup moves horizontally.
Problem is that the slid_btn do not holds its position inside the slid_line when the slid_line moves with the popup... :oops:

How could I make the Button holds its position inside the Line when the line moves? Is it possible?

Thanks in advance!!
B
28
S
14
G
6
Posts: 90
Reputation: 5,497

Post » Mon Sep 25, 2017 5:14 am

I'm wondering why you're using clamp for a set position? That feels unnecessary. It's possible I'm just not understanding what you're trying to do. Might you be able to post a gif or diagram explaining what you're doing?
B
82
S
48
G
32
Posts: 468
Reputation: 23,663

Post » Mon Sep 25, 2017 6:44 am

Yeah, you should share your CAPX, it's hard to understand without it.
Maybe you should temporary pin the slid_btn to the popup while it moves. Then unpin it once it stops.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,401
Reputation: 84,429

Post » Mon Sep 25, 2017 1:48 pm

Hey @Fenix18!

I'm not sure I understood it well, but have you tried pinning the button to the slider while it's moving and unpinning it when it stops moving?

Hope this helps. Cheers.
Bruno

I like to eat, but I'm no cook. Why liking to play games would make you a game designer?
B
22
S
6
G
3
Posts: 722
Reputation: 4,026

Post » Mon Sep 25, 2017 11:55 pm

Hey @ultrafop , @dop2000 , @brunopalermo , Thank you guys!!

I agree, my explanation wasn't very good :s...

Ultrafop, I'm using clamp because the Slide Bar tutorial that I found uses it. I think it's the best way of keeping the Slider Button inside the Slider Line, you will understand if you see the .capx.

A simple example:
https://www.dropbox.com/s/bt7rc1ydxzlg6 ... .capx?dl=0
Note that the values change when the popup moves, because the buttons do not stay in their position inside the line... I tried pinning, but It don't seems to work :?
B
28
S
14
G
6
Posts: 90
Reputation: 5,497

Post » Tue Sep 26, 2017 12:25 am

Fenix18 wrote:Hey @ultrafop , @dop2000 , @brunopalermo , Thank you guys!!

I agree, my explanation wasn't very good :s...

Ultrafop, I'm using clamp because the Slide Bar tutorial that I found uses it. I think it's the best way of keeping the Slider Button inside the Slider Line, you will understand if you see the .capx.

A simple example:
https://www.dropbox.com/s/bt7rc1ydxzlg6 ... .capx?dl=0
Note that the values change when the popup moves, because the buttons do not stay in their position inside the line... I tried pinning, but It don't seems to work :?


Oooooooh. I may actually have a fix for this in a project of mine. but I need to get to class so I hope this works for you as I won't be able t check for a few hours. Here is what I do in my project (with my 'on start' set to every tick for your purposes. I use an array to hold my variable that's being adjusted, which you'll see in my example):

every tick slider is not in touch -> set slider.x to (sliderbar.bboxright-slider.width) - (sliderbar.width*((5-array.at(your setting here)))/5)

EDIT: I should add that you can change that 5 to any number you want depending on your variable and your purposes, but the set of 5's needs to be changed to the same number to work correctly.
B
82
S
48
G
32
Posts: 468
Reputation: 23,663

Post » Tue Sep 26, 2017 1:16 am

@ultrafop, Man, I'm sorry, as a noob I didn't get you... Perhaps you could show me with the .capx? Please? If you would, I have no hurry.
B
28
S
14
G
6
Posts: 90
Reputation: 5,497

Post » Tue Sep 26, 2017 1:54 am

Hi, @Fenix18 I'm not sure if I understood properly is this what you need?

https://www.dropbox.com/s/3f5vd0yz9rahvze/SlidePopup1.capx?dl=0
B
54
S
33
G
95
Posts: 435
Reputation: 53,546

Post » Tue Sep 26, 2017 2:41 am

@tarek2 , Thank you very much! :) Is kind of that.

What I need is to bring the popup In and Out without changing the value of the Slider Bar (slid_line).
Like: If I bring the Popup In and set the value of the first bar to 60, when send the Popup Out of the screen, the value of the bar would remain 60.
What is happening is that I set the bar value to 60, and when I send the Popup out of the screen, the bar value goes to 0.
B
28
S
14
G
6
Posts: 90
Reputation: 5,497

Post » Tue Sep 26, 2017 3:20 am

Fenix18 wrote:@tarek2 , Thank you very much! :) Is kind of that.

What I need is to bring the popup In and Out without changing the value of the Slider Bar (slid_line).
Like: If I bring the Popup In and set the value of the first bar to 60, when send the Popup Out of the screen, the value of the bar would remain 60.
What is happening is that I set the bar value to 60, and when I send the Popup out of the screen, the bar value goes to 0.



I see what you mean, maybe like this?
https://www.dropbox.com/s/hhsaegcz6vwroy0/SlidePopup2.capx?dl=0

And also you can do it in less events
https://www.dropbox.com/s/t9i5b6z7rip1gml/SlidePopup3.capx?dl=0

you set your minimum value at the start of the layout then it only changes if the value is changed
Last edited by tarek2 on Tue Sep 26, 2017 8:50 am, edited 2 times in total.
B
54
S
33
G
95
Posts: 435
Reputation: 53,546

Next

Return to How do I....?

Who is online

Users browsing this forum: Lancifer and 0 guests