How do I scale a sprite with slider bar

Get help using Construct 2

Post » Wed Jun 22, 2016 12:14 pm

Hi!

I'd like to be able to scale a sprite with the help of a slider bar. I was thinking I could check if the slider is incrementing or decrementing in value, but there is no options to check that as far as I know. Do any one have any good suggestions?

Thanks!
Image
B
12
S
3
Posts: 37
Reputation: 839

Post » Wed Jun 22, 2016 12:53 pm

adventurist wrote:Hi!

I'd like to be able to scale a sprite with the help of a slider bar. I was thinking I could check if the slider is incrementing or decrementing in value, but there is no options to check that as far as I know. Do any one have any good suggestions?

Thanks!


Will this help?

https://www.dropbox.com/s/7pej6heehjs6lo4/spritescalebyslider.capx?dl=0

I've included a few comments in the .capx.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,387
Reputation: 58,456

Post » Wed Jun 22, 2016 3:05 pm

Thank you so much!

I fiddled with your code a bit, and I wonder how I could make it so it starts at its normal scale at 1 at the farthest right of the slider, and you can only downsize it and bring it up to its normal size again.

Hope you understand what I mean. :)
Image
B
12
S
3
Posts: 37
Reputation: 839

Post » Wed Jun 22, 2016 3:29 pm

adventurist wrote:Thank you so much!

I fiddled with your code a bit, and I wonder how I could make it so it starts at its normal scale at 1 at the farthest right of the slider, and you can only downsize it and bring it up to its normal size again.

Hope you understand what I mean. :)


Set the Slider property 'Value' = 100 (i.e. far right maximum)

Then SliderBar OnChanged - Set sprite.scale = SliderBar.Value/100

If you want to do away with the '/100' part of the 'SliderBar.Value/100'

Then you can just set the initial SliderBar proprties to:
Value =1
Minimum = 0
Maximum = 1
Step = 0.1 (or 0.01 etc for the number of steps between Min and Max you want)

Then you would just need

SliderBar OnChanged - Set sprite.scale = SliderBar.Value
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,387
Reputation: 58,456

Post » Wed Jun 22, 2016 5:19 pm

Awesome! Thank you for your time helping me out, works perfectly. :)
Image
B
12
S
3
Posts: 37
Reputation: 839

Post » Sun Apr 02, 2017 4:38 pm

Sorry for bumping an old thread, but since I can't send a PM to @zenox98... can you re-upload your example file? It's 404 on me.
B
28
S
8
G
1
Posts: 19
Reputation: 2,245

Post » Sun Apr 02, 2017 4:43 pm

RanTH wrote:Sorry for bumping an old thread, but since I can't send a PM to @zenox98... can you re-upload your example file? It's 404 on me.


Link updated.

Does it work now?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,387
Reputation: 58,456

Post » Sun Apr 02, 2017 5:15 pm

zenox98 wrote:
RanTH wrote:Sorry for bumping an old thread, but since I can't send a PM to @zenox98... can you re-upload your example file? It's 404 on me.


Link updated.

Does it work now?


Yes, thank you @zenox98 ! But I realized that I'm using this at an object which is a plugin, and it doesn't have "Set Scale" function. So I need to achieve this with "Set Width" and "Set Height"... could you help me with this?
B
28
S
8
G
1
Posts: 19
Reputation: 2,245

Post » Sun Apr 02, 2017 5:21 pm

I don't really understand what you mean by 'using this at an object which is a plugin'. Are you using some other plugin that doesn't come as standard with C2?

Maybe best if you provide your .capx for us to see what you are referring to, if possible.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,387
Reputation: 58,456

Post » Sun Apr 02, 2017 5:27 pm

zenox98 wrote:I don't really understand what you mean by 'using this at an object which is a plugin'. Are you using some other plugin that doesn't come as standard with C2?

Maybe best if you provide your .capx for us to see what you are referring to, if possible.


Sorry I can't upload with this capped internet I'm on.. yes it's not a standard C2 object. It has no "set scale" function.
I'm asking if you can modify your example but with Set Width and Height function to produce similar result.
B
28
S
8
G
1
Posts: 19
Reputation: 2,245


Return to How do I....?

Who is online

Users browsing this forum: ChoosyZerk and 72 guests