Basic camera functionality?

Hi All,

Can anyone help me get a basic app going that allows me to take a picture with the camera on my test hardware (3GS)?

Clearly I have hopes of doing more than just taking a single picture and saving it/viewing it but I figure this would be a nice place to start.

One step at a time :slight_smile:

I’m pretty exasperated. There’s some seemingly decent info out there on the forum/API reference but in the 5 hours I’ve spent on it, I can’t get anything to work.

Thanks in advance for your help :slight_smile: [import]uid: 105707 topic_id: 25496 reply_id: 325496[/import]

A good place to start is:

http://developer.anscamobile.com/reference/index/mediashow [import]uid: 17969 topic_id: 25496 reply_id: 103007[/import]

Thanks for the link. I’ve looked at that a bunch and just don’t seem to be getting it unfortunately.

Here’s a project I’ve been working on. My goal is to be able to use one button from the main scene to take a picture and then another button to switch scenes to view it. Do I seem to be on the right track? I have a bug related to my storyboard.gotoscene function that prevents me from successfully going to the 2nd scene. That’s weird to me becuase I pilaged this from something else I had worked on that did work!

This program does use the ui.lua library if anyone attempts to look at that.
main.lua
[blockcode]
display.setStatusBar(display.HiddenStatusBar)

local storyboard = require( “storyboard” )
local ui = require( “ui” )
image = display.newImage( “bg.jpg” )

local function newphoto ( event )
if (event.phase == “release”) then
media.show( media.Camera, sessionComplete )
return true
end
end

local function sessionComplete ( event )
t = event.target
local photot = display.newGroup()
photot:insert(t)
local baseDir = system.DocumentsDirectory
display.save(photot, “photo.jpg”, baseDir)
end

local button1Press = function( event )
newphoto ( event )
print( “\nbutton1Press function!” )
return true
end

local button1 = ui.newButton{
default = “buttonBlueSmall.png”,
over = “buttonBlueSmallOver.png”,
onPress = button1Press,
onRelease = button1Release,
text = “Shoot!”,
emboss = true
}

button1.x = 100; button1.y = 444

local button2Press = function( event )
–newphoto ( event )
print( “\nbutton2Press function!” )
storyboard.gotoScene( “photo_scene”, “slideLeft”, 800 )
return true
end

local button2 = ui.newButton{
default = “buttonBlueSmall.png”,
over = “buttonBlueSmallOver.png”,
onPress = button2Press,
onRelease = button2Release,
text = “View!”,
emboss = true
}

button2.x = 200; button2.y = 444

[/blockcode]
photo_scene.lua
[blockcode]
local baseDir = system.DocumentsDirectory
local img = display.newImage(“photo.jpg”,baseDir)
[/blockcode] [import]uid: 105707 topic_id: 25496 reply_id: 103012[/import]

Seems to be on the right track to me. Only thing that I can see without testing the code is that the sessionComplete ( event ) function should be placed above the newphoto ( event ) function in the programming. Not sure what kind of error you are getting? [import]uid: 17969 topic_id: 25496 reply_id: 103029[/import]

Thanks for the tip. I’m in the process of trying that out but the legitimate bug I have right now has to do with my storyboard gotoScene funtion… which is totally weird since I have used this successfully a number of times already…

I’m using build .777. I’m wondering if something has changed with the storyboard library?
[import]uid: 105707 topic_id: 25496 reply_id: 103210[/import]