Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is it possible to add pictures to assets while the app is working ?

in Examples Posts: 4

I want to make a game where the user can import a picture and use it as Player-figure.

Comments

  • dave1707dave1707 Mod
    Posts: 6,397

    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
    
  • Posts: 4

    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.

  • dave1707dave1707 Mod
    edited August 3 Posts: 6,397

    @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 Parakeet.jpg',gotImage)
        --http.request('https://dl.dropboxusercontent.com/s/3149mj9xjx1w71e/Costa Rican Frog.jpg',gotImage)
    end
    
    function gotImage(image,status,header)
        img=image
        saveImage("Documents:img1",img)
    end
    
  • edited August 18 Posts: 147

    @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

Sign In or Register to comment.