Howdy, Stranger!

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

Clone

How creat a clone of a sprite?

Comments

  • dave1707dave1707 Mod
    Posts: 7,612

    Need more information. What exactly do you want to do.

  • I want to creat clone of a sprite when we touch the screen of the iPad.

  • dave1707dave1707 Mod
    Posts: 7,612

    @goodboy2004 Do you want something like this. Tap a Sprite and it creates another at a random position.

    displayMode(FULLSCREEN) 
    
    function setup()
        tab={}
        table.insert(tab,vec2(WIDTH/2,HEIGHT/2))
        img=readImage("Planet Cute:Character Boy")
    end
    
    function draw()
        background(0)
        for a,b in pairs(tab) do
            sprite(img,b.x,b.y)
        end
    end
    
    function touched(t)
        if t.state==BEGAN then
            for a,b in pairs(tab) do
                if t.x>b.x-50 and t.x<b.x+50 and t.y>b.y-50 and t.y<b.y+50 then
                    table.insert(tab,vec2(math.random(50,WIDTH-50),
                            math.random(50,HEIGHT-50)))
                    return
                end
            end
        end    
    end
    
Sign In or Register to comment.