Solved. How do I limit rotation ?

Get help using Construct 2

Post » Sat Dec 24, 2016 6:05 am

Where do you put "sprite>rotate clamp(self.angle,50,150)"?

Nevermind. I found it.

For us new guys, when you pros give an answer, it might help if you state "In the event sheet, add a system event on every tick. Add a "set angle" action on the item you wish to clamp (such as player). Then enter sprite>rotate clamp(self.angle,225,315) and click done. That would have saved me a couple hours of feeling stupid :P
Last edited by Wicked Soft on Sat Dec 24, 2016 7:22 am, edited 1 time in total.
Image
B
18
S
9
G
3
Posts: 41
Reputation: 3,198

Post » Sat Dec 24, 2016 7:15 am

You can just type clamp, and the system will bring up the intellisense which gives you a selection of expressions you can use.
A non modal menu will also pop when you get to the action of setting the angle.
If you click on the system icon all the system expressions will appear, and you can select it from there, and fill it in manually.
clamp(self.angle, 50,150) will make sure that the angle can only be within the arc of 50 to 150 degrees.
Sprite.angle, or self.angle is the only value that can vary.

Would an example help?
Image ImageImage
B
172
S
50
G
183
Posts: 8,443
Reputation: 115,605

Post » Sat Dec 24, 2016 7:25 am

I found that in the manual. The problem is, I didn't have a clue what that expression meant. Nor did I know how to add it to my player sprite. I looked everywhere. Then I finally found an example capx file ;)

That's the reason I have never got into programming with javascript or vb. Because when I run into a problem, I don't know what I need to search for. You have to know thousands of codes in order to be able to get anything done. And that's just so you know where to look for answers when things don't work.

That is the problem I see here with Construct. Had I not stumbled onto this thread, I might still be looking for a way to stop my sprite from rotating. After searching for limit rotation I found I needed to use the clamp function. But it took me another hour or so to find where I needed to enter that line of uh hem... code.

Oh, thanks by the way LOL. I WOULD still be looking if not for your help hehe.
Image
B
18
S
9
G
3
Posts: 41
Reputation: 3,198

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 34 guests