Like a turned card

The last one is to replace your last for loop in the draw function. It will simply display 3 face down when only 3 cards are left in the deck, then 2 when 2 are left, etc.

As for the cards going off the screen, you would need to modify the y coordinate of the images as well as the x coordinate. I will get back to you shortly with the code.

-- Use this function to perform your initial setup
function setup()
    --b=Backup("Cards v105")
    img=readImage("Documents:Block") --image for back of card
    numDecks = 2
    deal()
    print("Turn the card!")
end

function touched(touched)
    -- this examines if the touch is within the rectangle's boundraries:
    if touched.state == ENDED then
        if CurrentTouch.x > 308 and CurrentTouch.x < 494 and CurrentTouch.y > 317 and CurrentTouch.y < 602 then
            cards[((52*numDecks)+1)-#p.pack]=p:nextCard()
        end
    end
end

function deal()
    c=Card(250,img)  --big cards 
    p=Pack(numDecks)
    cards={}
    cards[1]=p:nextCard()
end

-- This function gets called once every frame
function draw()
    -- This sets a background
    -- ipad size:2048,1536
    sprite("Documents:bg1", 512, 384, 1024, 768)
   -- sprite("Documents:cb", 401, 462, 186, 290)
    -- This sets the line thickness
    strokeWidth(5)

    -- Do your drawing here
    --draw our hand of cards
    --spread out cards to look nice
    for i,card in ipairs(cards) do
        c:draw(541+((i-1)%13)*24,555-math.floor((i-1)/13)*60,card.cardIndex,true)
    end
    --draw a pack face down
    for i=1,math.min(4,#p.pack) do
       c:draw(312+i*2,590-i*2,1,false) 
    end
end

Replace your main tab with the code above.

Verry nice, but the cards keep turning to the right of the screen. I want to draw the turned card exactly on top of the other turned cards. You know what i mean?
Sorry for my bad english

Replace

    for i,card in ipairs(cards) do
        c:draw(541+((i-1)%13)*24,555-math.floor((i-1)/13)*60,card.cardIndex,true)
    end

With

    for i,card in ipairs(cards) do
        c:draw(523,555,card.cardIndex,true)
    end

This will draw the flipped card in the same spot every time.

Alright but the left pack is a pack of 4 cards. Can we count the turned cards up to 4 cards and the turn on the same spot? like the left pack?

Are you flipping over 4 cards at once, or just showing 4 cards in this manner?

Pack - A B C D

Then placing cards over those 4

Pack - A B C D

To accomplish this, replace the same code as above with this code:

    for i,card in ipairs(cards) do
        c:draw(541+((i-1)%4)*24,555,card.cardIndex,true)
    end

Change 24 to a higher number if you want more space between the cards. If you want to see the whole card when flipped, I suggest moving the pack to the left by decreasing 312, and then move the flipped cards further left by also decreasing 541.

@slashin8r nice i was so close with coding it.
The following problem is, when you launch the game there is allready a flipped card. How do i start with none.

In your deal function, remove the line with the p:nextCard in it.