Sideways Camera

Nooby Question;

I currently have it when you touch the blue box a photo is added. On the camera it is sideways. It fixes itself if the user changes orientations, but how do I get it to be rotated the right way starting out? Thanks!

-- AddingPhotos

    supportedOrientations( LANDSCAPE_ANY)

-- Use this function to perform your initial setup
function setup()
    print("Hello World!")
    lines = {"testing 123", "kakakaakakkaak", "joy to the world."}
    dy = 0
    capturedimaged = nil
end

-- This function gets called once every frame
function draw()
    -- This sets a dark background color 
    background(40, 40, 50)

    -- This sets the line thickness
    strokeWidth(5)
    
    for i, v in ipairs(lines) do
        text(v, WIDTH/2, (HEIGHT/24)*(21-i)+(dy))
    end
    -- Do your drawing here
    local h = HEIGHT/10
    local w = WIDTH/1.25
    rectMode(CORNER)
    fill(106, 106, 106, 255)
    rect( 0, (dy)+HEIGHT-h, w, HEIGHT/10)
    rectMode( CENTER )
    fill(0, 1, 255, 255)
    rect( w/2, (dy)+(HEIGHT-h)+HEIGHT/20, WIDTH/10, HEIGHT/10)
    
end

function Camera()
    function draw()
   --     cameraSource(CAMERA_BACK, WIDTH/2)
        sprite(CAMERA, WIDTH/2, HEIGHT/2, WIDTH/2, HEIGHT/2 )
    end
end

function takephoto()
    capturedimaged = image(CAMERA_BACK)
end
    
function touched(t)
    if t.state==MOVING then
        dy = dy + t.deltaY
    end
    
    local a = WIDTH/1.25
    local b = WIDTH/20
    local c = HEIGHT - (HEIGHT/10)
    if CurrentTouch.x > (a/2)-b and CurrentTouch.x < (a/2)+b and CurrentTouch.y > c then
        Camera()
        print("ksks")
    end
end


@FearMe2142 There’s currently a problem with the camera orientation. Hopefully it will be fixed in a future release. You can use the changes below to correct it. Depending on how you hold your iPad, the value 270 might need to be changed to 90. You might want to use landscape_left or landscape_right and a specific value (90 or 270). I’m not sure if you’re doing this by mistake or intentionally, but your first draw() function is being replaced by the second draw() function in Camera() when you touch the button to take a picture.

function Camera()
    function draw()
   --     cameraSource(CAMERA_BACK, WIDTH/2)
        pushMatrix()
        translate(WIDTH/2,HEIGHT/2)
        rotate(270)
        sprite(CAMERA, 0, 0, WIDTH/2, HEIGHT/2 )
        popMatrix()
    end
end

While looking at this problem, I noticed that img=image(CAMERA) didn’t work. Img was returning nil. Doing a forum search showed that this was reported but I didn’t see a solution. After further research, img=image(CAMERA) does work, but you need to do it twice. Using the below code, the first screen touch returns nil for img, but a second touch will return an image.

function draw()
    if img~=nil then
        sprite(img,WIDTH/2,HEIGHT/2)
    end
end

function touched(t)
    if t.state==BEGAN then
        img=image(CAMERA)
        print(img)
    end
end

I have the sprite example working as shown in dave1707’s first example. However, if I replace “sprite(CAMERA, 0, 0, WIDTH/2, HEIGHT/2 )” with “Photo = image( CAMERA ),” the photo is still rotated. What am I missing?

Thanks