Javascript game, on touch or tilt the screen ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Javascript game, on touch or tilt the screen ?

want to creat a mini game, like Galaga arcade, but I don't know how to directing the ship tilting the screen or touching right or left side of the screen... (game code in javascript :P I will learn python and C# and C++ after. for Java, I don't want ^^)

28th Jul 2017, 9:18 AM
NoxFly
NoxFly - avatar
3 Answers
28th Jul 2017, 9:20 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 14
Use ondevicemotion and ontouchmove/ontouchstart events......
28th Jul 2017, 9:25 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 6
yes like this, thanks :)
28th Jul 2017, 9:21 AM
NoxFly
NoxFly - avatar