# How do I rotate a layer by pressing key?

Get help using Construct 2

### » 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

### » Tue Jan 05, 2016 5:38 pm

set layer angle to

(LayerAngle(0)+1)%360
B
85
S
31
G
12
Posts: 525
Reputation: 12,959

### » Tue Jan 05, 2016 5:59 pm

Lof wrote:set layer angle to

(LayerAngle(0)+1)%360

Sorry but not seemed to work

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

Thank you.
B
3
Posts: 4
Reputation: 183

### » 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
B
71
S
22
G
281
Posts: 3,842
Reputation: 154,886

### » Tue Jan 05, 2016 6:12 pm

YES! it works fine, thanks very much people.

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

### » 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.
B
85
S
31
G
12
Posts: 525
Reputation: 12,959