Soft Rotation

For questions about using Classic.

Post » Mon May 04, 2009 9:44 am

Make a sprite - arrow - with hotspot to left. As always event use the sprite's rotate toward position expression.

[code:22nk6mfk]System: Always (every tick)
> Sprite Rotate anglediff(Sprite.Angle, angle(Sprite.X, Sprite.Y, MouseX, MouseY)) * TimeDelta degrees toward (MouseX, MouseY)[/code:22nk6mfk]

Be creative, you can achieve any effect with custom expressions!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Mon May 04, 2009 3:33 pm

Ah, not working. :( Okay, if someone will be able to solve the prob, pm me, ok? Cheers a lot guys! :)
B
78
S
23
G
6
Posts: 234
Reputation: 7,662

Post » Mon May 04, 2009 4:47 pm

Your weapon sprite's graphics (sprite22) are drawn with its top upwards. In Construct the top of things should point towards the right if you want to use methods that use the angle like the 'rotate towards' method and make it behave as expected.

Construct will try to set the angle of any object tied to the bone behavior at every tick, so you'll have to set the angle to what you want to point it at instead at every tick as well.

I've rotated your weapon and added a sprite target cursor that you can move with the arrow up and down keys. At every tick, Construct will make the weapon point toward the target. You can get the .cap here.

EDIT: Seems like I misunderstood you earlier. You wanted the weapon to rotate smoothly towards the minimum and maximum aim angle and back to zero if no key was pressed. After some experimentation, I've made a solution that does that. It's a bit hard to explain how, so just have a look at the .cap.
B
1
G
3
Posts: 1
Reputation: 827

Post » Mon May 04, 2009 5:44 pm

[quote="Android-Music":33ez56n0]Ashley, could you make a cap please with key pressing events?[/quote:33ez56n0]
Have you tried some of the tutorials listed on the site? That's a pretty simple event so you might want to work on your general familiarity with the event sheet editor.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests