UPDATE: Resolved Need Help - Camera

I have created an expanded version of the Lua jump that I have decided to call “Jumpin’ Jack” and for the game I want users to be able to make themselves the character as a an extra feature. I have implemented the camera into my code, put I can not get it to take a picture. If anybody could please help it would be much appreciated.

Here is the link to the project: https://www.dropbox.com/s/zwdx8erz9i8efkx/JumpingJack.zip

UPDATE: Problem solved

Here’s some example code in how to do it:

function setup()
    parameter.action("Front camera",function() cameraSource(CAMERA_FRONT) end)
        parameter.action("Back camera",function() cameraSource(CAMERA_BACK) end)

function draw()
    background(40, 40, 50)
    if cap ~= nil then

function touched()
    cap = image(CAMERA)


Good luck!

@zoyt I am doing this exact thing, except using capturedImage instead of cap and yet it does not work. This is why I am confused. I have looked at the example and don’t see any differences.

your touched function seems to be inside your draw function. It needs to be separate.

function draw()
if main == true then
    function touched(touch)

After a looking a little more, i noticed that you have to tap the screen twice to get the image to be captured. I fixed that by calling “cap ~= image(CAMERA)” in setup. Here is my guess why this happens: The system needs time to access the camera. If you look at the camera app on iOS, you’ll notice that the app doesn’t switch cameras instantly. What I would do is set the variable you want to apply the camera to to the camera image, wait about 2 seconds, then capture it. If there is a better way to see if the camera is ready, somebody please let me know.

@Zoyt THANK YOU! It works now. I am very close to calling this project done, unless you have any suggestions for additional features…?