I want to make a game where the user can import a picture and use it as Player-figure.
You can add the assets you want to a table and use them. Tap the screen to show each asset at that spot.
displayMode(FULLSCREEN)
function setup()
pos={} -- x,y position touched
tab={readImage("Planet Cute:Character Boy"),
readImage("Planet Cute:Character Cat Girl"),
readImage("Planet Cute:Character Horn Girl"),
readImage("Planet Cute:Character Pink Girl"),
readImage("Planet Cute:Character Princess Girl")}
cnt=0
end
function draw()
background(0)
for a,b in pairs(pos) do
sprite(tab[a],pos[a].x,pos[a].y)
end
end
function touched(t)
if t.state==BEGAN then
if cnt<#tab then
cnt=cnt+1
pos[cnt]=vec2(t.x,t.y)
else
cnt=0
end
end
end
A realy nice idea to show something that’s still there, but if it was a ready app I can’t add own pictures to the app.
@lidddl Here’s an example of getting an image from someplace and saving it to Documents. If you don’t want to save it, it can just be used in the program. This is a large image, so it takes a sec or 2 to load.
displayMode(FULLSCREEN)
function setup()
getImg()
end
function draw()
background(40, 40, 50)
if img~=nil then
sprite(img,WIDTH/2,HEIGHT/2,700)
else
fill(255)
text("Loading image",WIDTH/2,HEIGHT/2)
end
end
function getImg()
http.request('https://dl.dropboxusercontent.com/s/33z3103t2hpcyjc/Pensive%20Parakeet.jpg',gotImage)
--http.request('https://dl.dropboxusercontent.com/s/3149mj9xjx1w71e/Costa%20Rican%20Frog.jpg',gotImage)
end
function gotImage(image,status,header)
img=image
saveImage("Documents:img1",img)
end
@lidddl If you want the user to be able to load an image into the project while it’s running, you can use pasteboard.image
. It wouldn’t be perfect, but it would still work