Everything from the file is below:
Config file settings under that.
Did a few tests there and for some reason the map stops moving when there is about 50 pixels more hidden off screen to the right even though the values for the position and xMin etc show the right values.
local leftSide = display.screenOriginX; local rightSide = display.contentWidth-display.screenOriginX; local topSide = display.screenOriginY; local bottomSide = display.contentHeight-display.screenOriginY; --------------------------------------------------------------------------------------- local composer = require "composer" local scene = composer.newScene() local widget = require "widget" local arrowRight local arrowLeft math.randomseed(os.time()) local function btnTouch( event ) if event.phase == "ended" then print ("button pressed") composer.gotoScene(event.target.btnDestination, {time=250, effect="crossFade"}) return true end end local function locationTouch( event ) if event.phase == "ended" then print (myCurrentImage.currentImageIndex) if myCurrentImage.currentImageIndex == 1 then composer.gotoScene("cork\_poi", {time=250, effect="crossFade"}) end if myCurrentImage.currentImageIndex == 2 then composer.gotoScene("cork\_poi", {time=250, effect="crossFade"}) end if myCurrentImage.currentImageIndex == 3 then composer.gotoScene("cork\_poi", {time=250, effect="crossFade"}) end if myCurrentImage.currentImageIndex == 4 then composer.gotoScene("cork\_poi", {time=250, effect="crossFade"}) end if myCurrentImage.currentImageIndex == 5 then composer.gotoScene("cork\_poi", {time=250, effect="crossFade"}) end if myCurrentImage.currentImageIndex == 6 then composer.gotoScene("cork\_poi", {time=250, effect="crossFade"}) end if myCurrentImage.currentImageIndex == 7 then composer.gotoScene("cork\_poi", {time=250, effect="crossFade"}) end return true end end -- Called when the scene's view does not exist: function scene:create( event ) local sceneGroup = self.view local footerGroup = display.newGroup() local map = display.newImageRect("images/dublinMap.jpg", 1064, 636) map.x = display.contentCenterX map.y = display.contentCenterY sceneGroup:insert( map ) local Footerbg = display.newImageRect("images/footerbg.jpg", 360, 60) Footerbg.x = display.contentCenterX Footerbg.y = bottomSide -30 Footerbg.isVisible = false; sceneGroup:insert( Footerbg ) -- code to slide through locations -- myImages = {"images/Dublin/location1.jpg", "images/Dublin/location2.jpg", "images/Dublin/location3.jpg", "images/Dublin/location4.jpg", "images/Dublin/location5.jpg", "images/Dublin/location6.jpg", "images/Dublin/location7.jpg", "images/Dublin/location8.jpg", "images/Dublin/location9.jpg", "images/Dublin/location10.jpg" } -- name of images currentImageIndex = 1 -- this is index to track your current image -- display the first image myCurrentImage = display.newImageRect( myImages[1],240,60) myCurrentImage.x = display.contentCenterX myCurrentImage.y = bottomSide -30 myCurrentImage.currentImageIndex = 1 sceneGroup:insert( myCurrentImage ) myCurrentImage:addEventListener( "touch", locationTouch ) -- Function to handle back and forward buttons local function handleButtonEvent( event ) if ( "ended" == event.phase ) then if event.target.id == "back" and currentImageIndex \> 1 then print( "Back" ) myCurrentImage:removeSelf() myCurrentImage = nil myCurrentImage = display.newImage( myImages[currentImageIndex - 1]) myCurrentImage.x = display.contentCenterX myCurrentImage.y = bottomSide -30 sceneGroup:insert( myCurrentImage ) arrowLeft:toFront() arrowRight:toFront() currentImageIndex = currentImageIndex - 1 myCurrentImage.currentImageIndex = currentImageIndex myCurrentImage:addEventListener( "touch", locationTouch ) elseif event.target.id == "fwd" and currentImageIndex \< 10 then print( "fwd" ) myCurrentImage:removeSelf() myCurrentImage = nil myCurrentImage = display.newImage( myImages[currentImageIndex + 1]) myCurrentImage.x = display.contentCenterX myCurrentImage.y = bottomSide -30 sceneGroup:insert( myCurrentImage ) arrowLeft:toFront() arrowRight:toFront() currentImageIndex = currentImageIndex + 1 myCurrentImage.currentImageIndex = currentImageIndex myCurrentImage:addEventListener( "touch", locationTouch ) end return true end end -- drag map function -- local function moveMap( event ) xMax = display.screenOriginX + map.width/2; xMin = display.screenOriginX - 260 ; yMax = display.screenOriginY + map.height/2; yMin = display.screenOriginY + map.height/2; local t = event.target local phase = event.phase if "began" == phase then t.isFocus = true -- Store initial touch position on the actual object - prevents jumping when touched t.xStart = event.x - t.x t.yStart = event.y - t.y elseif t.isFocus then if "moved" == phase then print( display.actualContentWidth ) print("posx:"..t.x) print("xMin:"..xMin) print("xMax:"..xMax) print("pos:"..t.y) print("yMin:"..yMin) print("yMax"..yMax) t.x = event.x - t.xStart t.y = event.y - t.yStart if (t.x \> xMax) then t.x = xMax end if (t.x \< xMin) then t.x = xMin end if (t.y \> yMax) then t.y = yMax end if (t.y \< yMin) then t.y = yMin end elseif "ended" == phase or "cancelled" == phase then t.isFocus = false end end --This tells the system that the event -- should not be propagated to listeners of any objects underneath. return true end -- end of drag map function -- map:addEventListener( "touch", moveMap ) arrowLeft = display.newImageRect("images/arrowLeft.png", 12, 21) arrowLeft.x = display.screenOriginX+20 arrowLeft.y = bottomSide -40 arrowLeft:toFront( ) arrowLeft.id = "back" arrowLeft:addEventListener( "touch", handleButtonEvent ) sceneGroup:insert( arrowLeft ) arrowRight = display.newImageRect("images/arrowRight.png", 12, 21) arrowRight.x = display.contentWidth-display.screenOriginX -20; arrowRight.y = bottomSide -40 arrowRight:toFront( ) arrowRight.id = "fwd" arrowRight:addEventListener( "touch", handleButtonEvent ) sceneGroup:insert( arrowRight ) local function moveToFront( ) arrowRight:toFront( ) arrowLeft:toFront( ) end local back = display.newImageRect("images/button\_dublin.jpg", 360, 40) back.x = display.contentCenterX back.y = display.screenOriginY+20; back.btnDestination = "Scene1" back:addEventListener( "touch", btnTouch ) sceneGroup:insert( back ) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if "did" == phase then print( "1: show event, phase did" ) -- remove previous scene's view --composer.removeScene( "main" ) end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if "will" == phase then print( "1: hide event, phase will" ) -- remove touch listener for image --audioBtn:removeEventListener( "touch", myAudio ) --back:removeEventListener( "touch", btnTouch ) -- remove audio audio.stop() audio.dispose( audioSound ) audioSound = nil -- cancel timer -- timer.cancel( memTimer ); memTimer = nil; end end function scene:destroy( event ) print( "((destroying scene 1's view))" ) local sceneGroup = self.view end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) --------------------------------------------------------------------------------- return scene
Config file
application = { content = { width = 320, height = 480, scale = "letterbox", xAlign = "center", yAlign = "center", imageSuffix = { ["@2x"] = 1.5, }, } }
Cheers for having a look