Hello, I am creating an app that when playing on some card it is selected and creates a button to send the card to a deck when it is pressed, I have some difficulty in:
1 - Make the cards fill the total width of any device respecting the proportion and the space of 8 pixels.
2 - When playing the card, the button does not appear in the middle of the card
3 - At the touch of the button, I would like the card to transition to the green deck at the top of the screen and the other cards fill the void left by the card selected for the deck.
I’m using Corona 2018.3326 on Windows 7, I’m creating the main base app on iOS, first testing on the iPhone 4S simulator
local composer = require( "composer" ) local widget = require("widget") local scene = composer.newScene() local mFloor = math.floor local myCardsRef, cards = {}, {} local lastTappedCard local navBar local scrollView local deck local sizeDeck = (display.contentHeight \* 45 / 100) - 64 local title local cardDeck1 local cardDeck2 local cardDeck3 local cardDeck4 local cardDeck5 local cardDeck6 local cardDeck7 local cardDeck8 local button function scene:create( event ) local sceneGroup = self.view navBar = display.newRect(sceneGroup,0, 0,display.contentWidth, 64) navBar.anchorX = 0 navBar.anchorY = 0 navBar:setFillColor(1,0,0) deck = display.newRect(sceneGroup,0, navBar.y + navBar.height,display.contentWidth, sizeDeck) deck.anchorX = 0 deck.anchorY = 0 deck:setFillColor(1,1,0) title = display.newText(sceneGroup,"Home",display.contentCenterX, navBar.y + navBar.height - 20,nil, 17) title:setFillColor(1,1,1) cardDeck1 = display.newRect(sceneGroup, 45,deck.y + 8,50,65) cardDeck1.anchorX = 0 cardDeck1.anchorY = 0 cardDeck1:setFillColor(0,1,0) cardDeck2 = display.newRect(sceneGroup, cardDeck1.x + cardDeck1.width + 8,deck.y + 8,50,65) cardDeck2.anchorX = 0 cardDeck2.anchorY = 0 cardDeck2:setFillColor(0,1,0) cardDeck3 = display.newRect(sceneGroup, cardDeck2.x + cardDeck2.width + 8,deck.y + 8,50,65) cardDeck3.anchorX = 0 cardDeck3.anchorY = 0 cardDeck3:setFillColor(0,1,0) cardDeck4 = display.newRect(sceneGroup, cardDeck3.x + cardDeck3.width + 8,deck.y + 8,50,65) cardDeck4.anchorX = 0 cardDeck4.anchorY = 0 cardDeck4:setFillColor(0,1,0) cardDeck5 = display.newRect(sceneGroup, 45,cardDeck1.y + cardDeck1.height + 8,50,65) cardDeck5.anchorX = 0 cardDeck5.anchorY = 0 cardDeck5:setFillColor(0,1,0) cardDeck6 = display.newRect(sceneGroup, cardDeck5.x + cardDeck5.width + 8,cardDeck1.y + cardDeck1.height + 8,50,65) cardDeck6.anchorX = 0 cardDeck6.anchorY = 0 cardDeck6:setFillColor(0,1,0) cardDeck7 = display.newRect(sceneGroup, cardDeck6.x + cardDeck6.width + 8,cardDeck1.y + cardDeck1.height + 8,50,65) cardDeck7.anchorX = 0 cardDeck7.anchorY = 0 cardDeck7:setFillColor(0,1,0) cardDeck8 = display.newRect(sceneGroup, cardDeck7.x + cardDeck7.width + 8,cardDeck1.y + cardDeck1.height + 8,50,65) cardDeck8.anchorX = 0 cardDeck8.anchorY = 0 cardDeck8:setFillColor(0,1,0) scrollView = widget.newScrollView( { top = display.contentHeight - display.contentHeight \* 55 / 100, left = 0, width = display.contentWidth, height = display.contentHeight \* 55 / 100, scrollWidth = 600, horizontalScrollDisabled = true, scrollHeight = 1300, listener = scrollListener } ) sceneGroup:insert(scrollView) for i=1, 86 do cards[#cards + 1] = { name = 'card'..i..'.png', x = 8 + ( i - 1 ) % 4 \* 76, y = 8 + ( mFloor( ( i - 0.5 ) / 4 ) \* 98 ), w = (display.contentWidth - 40) / 4, h = 90 } end print((scrollView.width - 40) / 4) local function tap( self, event ) if lastTappedCard then myCardsRef[lastTappedCard].alpha = 1 button:removeSelf() button = nil end myCardsRef[self].alpha = 0.5 button = display.newRect(event.x,event.y, 50, 30) button:setFillColor(0,0,0) lastTappedCard = self end for index = 1, #cards do local card = display.newRect(cards[index].x,cards[index].y,cards[index].w,cards[index].h) card.anchorX = 0 card.anchorY = 0 card:setFillColor( 1, 0, 0 ) card.tap = tap card:addEventListener( "tap" ) scrollView:insert( card ) myCardsRef[card] = card end end