Volume Control

For questions about using Classic.

Post » Sun Dec 26, 2010 12:42 pm

Hi. I need a volume control which is controlled by the mouse. When a player clicks on any part of the circle, then moving the mouse he increases or decreases the volume. How to make a circle to rotate when you click on any part of it?
B
1
G
2
Posts: 7
Reputation: 639

Post » Sun Dec 26, 2010 1:23 pm

>mouse is over object
>mouse button left is down
->object set angle towards position mousex, mousey

>xaudio2 set volume to clamp(object angle, min volume, max volume)

... with object angle preset to 0
Might want to put a lerp in there to use more of the circumference.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sun Dec 26, 2010 2:30 pm

Thanks. I made as you said, but the circle jerks when I try to spin it anywhere. It must begin rotate from the point where it has stopped. And I don't know how to use lerp, can you help me, please?
B
1
G
2
Posts: 7
Reputation: 639

Post » Sun Dec 26, 2010 7:23 pm

I've tried multiple variants, but can't make it. Here is what I have got. example v.3 Does anyone have any ideas?

B
1
G
2
Posts: 7
Reputation: 639

Post » Sun Dec 26, 2010 11:20 pm

This is probably a better way to do it using the actual values, and just clockwise/ counter clockwise.
[url:203o1ccd]http://dl.dropbox.com/u/666516/vcControl.zip[/url:203o1ccd]
Keep in mind you can have negative values on the volume.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Dec 27, 2010 12:00 pm

Thank you Newt, but your version is not suitable for me, because I need control rotates only when we move the mouse. I've almost made this, you can watch on video or download a cap file below. The only thing I couldn't get is to remove jerks which unaccountably appear sometimes when rotating the volume control and spoil the view.

video: http://www.youtube.com/watch?v=AV4ITn9dOrM

cap file: http://dl.dropbox.com/u/10760635/example_v.4.cap

Why does the volume control often jerk and abruptly change the angle? How to fix this?
B
1
G
2
Posts: 7
Reputation: 639

Post » Mon Dec 27, 2010 12:13 pm

Yeah, that's the reason I went for the other way.
There's no such thing as an angle above 360, likewise none below 0, so it resets.
All you can do is compare the sprites angle to make sure it doesn't go above or below.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Dec 27, 2010 1:22 pm

[quote="newt":1m764bbm]All you can do is compare the sprites angle to make sure it doesn't go above or below.[/quote:1m764bbm]

I compare the sprites angle, look at the this screenshot:



Maybe I'm doing something wrong. If so, tell me please how to make the correct event that would compare the angles and the circle would move without jerks?

Is there any plugin?

Or this program cannot to make a simple volume control controlled by the mouse?

B
1
G
2
Posts: 7
Reputation: 639

Post » Mon Dec 27, 2010 5:59 pm

The problem becomes much simpler if you use only the change in MouseX to rotate the dial:
[url:2jm8o0m3]http://dl.dropbox.com/u/5426011/examples3/dial2.cap[/url:2jm8o0m3] made in 0.99.96

Here's an example of a dial the way you've been doing it with the angle to the mouse. The range of motion is from 135 degrees clockwise to 45 degrees, which is about the range of motion that real volume dials have.
[url:2jm8o0m3]http://dl.dropbox.com/u/5426011/examples3/Dial3.cap[/url:2jm8o0m3] made in 0.99.96

cheers
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Mon Dec 27, 2010 6:44 pm

I've downloaded both caps, it looks very seriously, but most importantly - it works! I will necessarily try to understand this. Thank you guys! :D
B
1
G
2
Posts: 7
Reputation: 639

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests