Hey guys I feel so dumb right now cause I cant figure out how to make my game fit multiple devices screens and have every object be in the right position. Because everything turns out on the simulator but not on real devices.
level1.lua
local composer = require( "composer" ) local scene = composer.newScene() -- ----------------------------------------------------------------------------------------------------------------- -- All code outside of the listener functions will only be executed ONCE unless "composer.removeScene()" is called. -- ----------------------------------------------------------------------------------------------------------------- -- local forward references should go here -- ------------------------------------------------------------------------------- local physics = require("physics") -- "scene:create()" function scene:create( event ) local sceneGroup = self.view --make background------------------------------------- local bg = display.newImage("level1.png",239,160) bg:scale(1.25,1) physics.start() canmove = false motionx = 0; -- Variable used to move character along x axis speed = 6; -- Set Walking Speed health = 10 ammo = 5 local sheetData1 = { frames = { { name="Idle (10)\_70x69.png", x="148", y="60" ,width="35", height="59"}, { name="Idle (2)\_70x69.png", x="37", y="0" ,width="35", height="59"}, { name="Idle (3)\_70x69.png" ,x="0" ,y="60", width="35", height="58"}, { name="Idle (4)\_70x69.png" ,x="0", y="0" ,width="35", height="58"}, { name="Idle (5)\_70x69.png" ,x="74" ,y="0" ,width="35", height="58"}, { name="Idle (6)\_70x69.png" ,x="148", y="0", width="35" ,height="58"}, { name="Idle (7)\_70x69.png" ,x="111" ,y="60" ,width="35", height="58"}, { name="Idle (8)\_70x69.png", x="111", y="0", width="35", height="58"}, { name="Idle (9)\_70x69.png" ,x="74", y="60" ,width="35" ,height="59"}, }, sheetContentWidth = 256, sheetContentHeight = 128 } --1st image sheet local sheet1 = graphics.newImageSheet("sprites.png",sheetData1) --2nd images sheet local sheetData2 = { frames = { { name="Run (1)\_70x69.png", x="78", y="124", width="32", height="61"}, { name="Run (2)\_70x69.png", x="44", y="124" ,width="32", height="62"}, { name="Run (3)\_70x69.png" ,x="0", y="62" ,width="42", height="59"}, { name="Run (4)\_70x69.png", x="0", y="188" ,width="40" ,height="60"}, { name="Run (5)\_70x69.png" ,x="44" ,y="62" ,width="38" ,height="60"}, { name="Run (6)\_70x69.png", x="0" ,y="123" ,width="42", height="63"}, { name="Run (7)\_70x69.png" ,x="0", y="0" ,width="46" ,height="60"}, { name="Run (8)\_70x69.png" ,x="42", y="188" ,width="39" ,height="60"}, }, sheetContentWidth = 128, sheetContentHeight = 256 } local sheet2 = graphics.newImageSheet("sprites1.png",sheetData2) local sequenceData = { {name = "idle",sheet = sheet1,start=1,count=10,time= 600,loopCount = 0}, {name = "run",sheet = sheet2,start=1,count=8,time= 600,loopCount = 0} } local eric = display.newSprite( sheet1, sequenceData ) eric.x = display.contentWidth/2 ; eric.y = display.contentHeight/2 eric:play() physics.addBody(eric,"dynamic") local platform = display.newImage("platform.png",230,270) physics.addBody(platform,"static") --make buttons----------------------------------------- local btnR = display.newImage("buttonR.png",470,285) btnR:scale(0.3,0.3) local btnL = display.newImage("buttonL.png",10,285) btnL:scale(0.3,0.3) local btnUP = display.newImage("buttonUP.png",10,285) btnUP:scale(0.3,0.3) local sheild = display.newImage("shield.png",380,285) sheild:scale(0.08,0.08) ------------------------------------------------------- --make function for moving----------------------------- function btnL:touch() motionx = -speed; end btnL:addEventListener("touch",btnL) function btnR:touch() motionx = speed; local function swapSheet() eric:setSequence( "run" ) eric:play() end timer.performWithDelay( 200, swapSheet ) end btnR:addEventListener("touch",btnR) local function moveeric (event) eric.x = eric.x + motionx; end Runtime:addEventListener("enterFrame", moveeric) local function stop (event) if event.phase =="ended" then motionx = 0; end end Runtime:addEventListener("touch", stop ) local dialogue1 = display.newText("Welcome to the bunker let me teach you the basics!",240,50,"alienleague.ttf",20) local function removed1( event ) display.remove(dialogue1) end local function moveinstruc( event ) local instruc = display.newText("Use the arrows down below to move left and right",240,50,"alienleague.ttf",20) end local heart1 = display.newImage("heart.png",-20,20) heart1:scale(0.1,0.1) local heart2 = display.newImage("heart.png",20,20) heart2:scale(0.1,0.1) local heart3 = display.newImage("heart.png",60,20) heart3:scale(0.1,0.1) local function makeenemy( event ) local enemy = display.newRect(400,170,100,150) physics.addBody(enemy,"dynamic") local function enemyshoot(event) local bullet1 = display.newImage("bullet1.png",enemy.x,enemy.y) bullet1.rotation = 180 bullet1:scale(0.5,0.5) transition.to( bullet1, { time=3000, alpha=0,x=eric.x,y=eric.y } ) end timer.performWithDelay( 5000, enemyshoot,-1 ) end local function enemyshoot1(event) local bullet10 = display.newImage("bullet1.png",eric.x,eric.y) bullet10:scale(0.1,0.1) transition.to( bullet10, { time=3000, alpha=0,x=event.x,y=event.y } ) end Runtime:addEventListener("tap",enemyshoot1) --event Listners--------------------------------------- timer.performWithDelay( 5000, removed1 ) timer.performWithDelay( 6000, moveinstruc ) timer.performWithDelay( 8000, makeenemy ) --make sceneGroups------------------------------------- --make scenegroups------------------------------------- sceneGroup:insert(bg) sceneGroup:insert(platform) sceneGroup:insert(eric) sceneGroup:insert(btnUP) sceneGroup:insert(btnL) sceneGroup:insert(btnR) sceneGroup:insert(heart1) sceneGroup:insert(heart2) sceneGroup:insert(heart3) ------------------------------------------------------- ------------------------------------------------------- end
config.lua
application = { content = { width = 320, height = 480, scale = "letterBox", fps = 30, --[[imageSuffix = { ["@2x"] = 2, }, --]] }, --[[-- Push notifications notification = { iphone = { types = { "badge", "sound", "alert", "newsstand" } } }, --]] }