Did you trying make screen shake?
In corona it was very easy, but here I don’t know how to do that.
First you need to create a Camera, you can do that by creating a GameObject and adding the camera object. Attatch a script to the camera and make it acquire_camera_focus on init. Position it in a good place in your collection.
I used Perlin noise to make the Camera shake feel a bit more natural. I´ve shared my implementation of the camera script and Perlin noise on dropbox.
The script takes a message called “shake” with a duration parameter, the duration is the number of frames it should last for. You might want to change this to seconds and use dt in the update method for the timer.
You can change the range of the shake by modifying this parameter.
self.shake_range = vmath.vector3(15,15,1)
Files
- camera.script - The camera script
- perlin.lua - A lua module for creating noise, put it in “modules” directory in the root, or change the require in the camera script to your directory for the module.
Enjoy and good luck!
That’s great! @Jens_Andersson
Thank you, it was very helpful