After indentation and a quick walkthrough with the debugger using stop points at your labels (this is before even looking at your actual code), it appears your buttons exit the do loop and never return, leading your program to dive off the deep end into obscurity and probably self-termination.
SetVirtualResolution ( 320, 480 )
setsyncrate(30,0)
goto label_home
label_home:
rem set up two buttons 'Cam' to take a picture to be set as the background
rem 'Open' to open an image from memory to select and set it as the background
AddVirtualButton(1,250,440,90)
SetVirtualButtonText(1,"Cam")
SetVirtualButtonColor(1,255,0,0)
SetVirtualButtonVisible(1,1)
AddVirtualButton( 2,80,440,90 )
SetVirtualButtonText( 2, "Open" )
SetVirtualButtonColor(2,255,0,0)
SetVirtualButtonVisible(2,1)
GetVirtualButtonPressed(1)
GetVirtualButtonPressed(2)
rem check if the buttons are pressed
do
if GetVirtualButtonPressed(1) =1
goto label_capturebackgroundimage
endif
if GetVirtualButtonPressed(2) =1
goto label_gallery
endif
sync()
loop
rem take a photo and save it as 'bkg.png'
label_capturebackgroundimage:
gallery = ShowImageCaptureScreen()
if gallery = 1
while IsCapturingImage() = 1
sync()
endwhile
imageID = GetCapturedImage()
if imageID = 1
SaveImage(imageID,"bkg.png")
goto label_shoot
endif
rem open up the gallery to select an image from the image folder and save it at 'bkg.png'
label_gallery:
if ShowChooseImageScreen()=1
while IsChoosingImage()=1
sync()
endwhile
image = GetChosenImage()
SaveImage(image,"bkg.png")
goto label_shoot
endif
rem open up 'bkg.png' and set it as the background
label_shoot:
LoadImage(1,"bkg.png")
createsprite(1,1)
SetspriteVisible(1,1)
SetSpritesize( 1, 256,256 )
SetSpriteAngle(1,90)
setspriteposition(1,0,0)
setSpriteDepth(1,1000)
drawsprite(1)
render()
rem load the ball and hide it until the screen is pressed.
rem then when the screen is pressed show the ball on top of the background in the position where the screen was pressed.
LoadImage(2,"ball.png")
createsprite(2,2)
setspritesize(2,50,50)
SetspriteVisible(2,0)
if getpointerpressed() = 1
x=getpointerx()
y=getpointery()
endif
if getpointerpressed() = 0
x=1000
y=1000
endif
if getspritehittest(1,x,y) = 1
SetSpritePosition(2,x,y)
SetspriteVisible(2,1)
endif
endif
I'll see if I can't get you back on track without mussing it up.
EDIT: I only made a couple of changes here. I changed your gotos to gosubs, since it appeared you were using them more like subroutines. I also changed if imageID = 1 to if imageID > 1 because you theoretically don't know what the image ID will be. FYI, IDs assigned by the compiler will start at 10001, so imageID = 10001 would have also worked, but imageID = 1 would never be true.
SetVirtualResolution ( 320, 480 )
setsyncrate(30,0)
goto label_home
label_home:
rem set up two buttons 'Cam' to take a picture to be set as the background
rem 'Open' to open an image from memory to select and set it as the background
AddVirtualButton(1,250,440,90)
SetVirtualButtonText(1,"Cam")
SetVirtualButtonColor(1,255,0,0)
SetVirtualButtonVisible(1,1)
AddVirtualButton( 2,80,440,90 )
SetVirtualButtonText( 2, "Open" )
SetVirtualButtonColor(2,255,0,0)
SetVirtualButtonVisible(2,1)
GetVirtualButtonPressed(1)
GetVirtualButtonPressed(2)
rem check if the buttons are pressed
do
if GetVirtualButtonPressed(1) =1
gosub label_capturebackgroundimage
endif
if GetVirtualButtonPressed(2) =1
gosub label_gallery
endif
sync()
loop
rem take a photo and save it as 'bkg.png'
label_capturebackgroundimage:
gallery = ShowImageCaptureScreen()
if gallery = 1
while IsCapturingImage() = 1
sync()
endwhile
imageID = GetCapturedImage()
if imageID > 1
SaveImage(imageID,"bkg.png")
gosub label_shoot
endif
endif
return
rem open up the gallery to select an image from the image folder and save it at 'bkg.png'
label_gallery:
if ShowChooseImageScreen()=1
while IsChoosingImage()=1
sync()
endwhile
image = GetChosenImage()
SaveImage(image,"bkg.png")
gosub label_shoot
endif
return
rem open up 'bkg.png' and set it as the background
label_shoot:
LoadImage(1,"bkg.png")
createsprite(1,1)
SetspriteVisible(1,1)
SetSpritesize( 1, 256,256 )
SetSpriteAngle(1,90)
setspriteposition(1,0,0)
setSpriteDepth(1,1000)
drawsprite(1)
render()
rem load the ball and hide it until the screen is pressed.
rem then when the screen is pressed show the ball on top of the background in the position where the screen was pressed.
LoadImage(2,"ball.png")
createsprite(2,2)
setspritesize(2,50,50)
SetspriteVisible(2,0)
if getpointerpressed() = 1
x=getpointerx()
y=getpointery()
endif
if getpointerpressed() = 0
x=1000
y=1000
endif
if getspritehittest(1,x,y) = 1
SetSpritePosition(2,x,y)
SetspriteVisible(2,1)
endif
return