How do I set the maximum width for a sprite?

Get help using Construct 2

Post » Wed Oct 07, 2015 5:41 pm

How do I set the maximum width for a sprite and maximum value for an instance variable?
*misses old games*
B
20
S
4
G
4
Posts: 147
Reputation: 3,193

Post » Wed Oct 07, 2015 5:59 pm

Would the clamp expression help?

clamp(x,lower,upper)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 6:55 pm

If I knew to implement that :) There's not many good tutorials for top down games.. I watched many, but they don't teach the stuff I really need so sry if im boring you :/
*misses old games*
B
20
S
4
G
4
Posts: 147
Reputation: 3,193

Post » Wed Oct 07, 2015 7:39 pm

It's an expression..

From the manual:

clamp(x, lower, upper)
Return lower if x is less than lower, upper if x is greater than upper, else return x.

System every tick
> sprite set width : clamp(self.width,10,200)

this way the width of the sprite can never be more than 200 or less than 10
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 7:40 pm

Also a simple event like:

Sprite.width > 200
-- sprite set width : 200

Does the trick..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Oct 07, 2015 9:03 pm

Yeah I tried the simple way before I made this post, didnt work :P The every tick suggestion worked, ty
*misses old games*
B
20
S
4
G
4
Posts: 147
Reputation: 3,193


Return to How do I....?

Who is online

Users browsing this forum: mattshallow, Yahoo [Bot] and 23 guests