How do I rotate a layer by pressing key?

Get help using Construct 2

Post » Tue Jan 05, 2016 5:07 pm

I'm new in this forum, excuse me for my bad english.

I tried to make a layer Rotate continuosly when the key "o" and "p" are pressed in clockwise and counterclockwise direction.

I've tried with the event shown below:
Keyboard - O is down – System - Set layer 1 angle to LayerAngle(0)+10 degrees

But layer rotate by 10 degree and stop, i don't know how to continue the rotation.

Anyone can help me?

Regards and happy new year to anyone in the forum.
Last edited by WildboreMarco on Tue Jan 05, 2016 5:41 pm, edited 1 time in total.
B
3
Posts: 4
Reputation: 183

Post » Tue Jan 05, 2016 5:38 pm

set layer angle to

(LayerAngle(0)+1)%360
Image
B
80
S
30
G
12
Posts: 517
Reputation: 12,713

Post » Tue Jan 05, 2016 5:59 pm

Lof wrote:set layer angle to

(LayerAngle(0)+1)%360


Sorry but not seemed to work
Image

Layer rotate by 1 degrees and stop rotation, i need to include another event?

Thank you.
B
3
Posts: 4
Reputation: 183

Post » Tue Jan 05, 2016 6:02 pm

LayerAngle(x) takes the level number, so in your case you need LayerAngle(1).
https://www.scirra.com/manual/126/system-expressions
ImageImageImage
B
71
S
22
G
247
Posts: 3,756
Reputation: 137,558

Post » Tue Jan 05, 2016 6:12 pm

YES! it works fine, thanks very much people.

The right code is:
Image
B
3
Posts: 4
Reputation: 183

Post » Tue Jan 05, 2016 8:46 pm

the (1) represents the layer number, you can alternately write the layer name ("background"), this is more efficient, because if you add more layers later or change the order, it will still effect the "background" layer and not the layer numbered 1.
Image
B
80
S
30
G
12
Posts: 517
Reputation: 12,713


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 42 guests