(This mini-course is aimed at mobile devices with touch screens.)
Moving a player around the screen happens in most games, and while you can use D-Pads and other onscreen controls, why not take advantage of the touch screen instead of trying to recreate an analog joystick?
If you’ve ever wanted to allow users to swipe the screen and move the player character, puzzle pieces, etc., this mini-tutorial is for you! This same code is being used in published games right now, and you can start using it in your own games in just minutes!
Use the included code to receive swipes of left, right, up, and down, according to how the user swipes on the screen. Use it for moving objects, setting directions, and more.
This mini-tutorial includes a swipe function that can be used over and over again in all your games. It’s easy to implement and I’ll show you how to move your character two different ways:
- Using transition.to()
- Using setLinearVelocity() with Physics
The physics-based demo is actually the foundation of a Space Invaders-type game that you can polish up and even publish, if you like!
Use the included code to receive swipes of left, right, up, and down.
Level: Beginner to Intermediate
Content: Code, Demo, and Tutorial Videos
Jay has been programming professionally since 1988, starting with game programming and then over the years moving to internet programming with a major Seattle telecommunications firm. Jay started programming for mobile devices in 2010 and currently has several games and apps in the Apple App Store with more on the way.
In addition to writing scores of technical articles over the years, Jay has recorded dozens of hours of tutorial videos. He's been a speaker at technical conferences and enjoys teaching how to make games and apps almost as much as making games and apps themselves.
Jay is a Certified Developer with Corona SDK and has created a computer science course for the University of Alaska on using Unity to make 2D games.