roaminggamer, the question does sound strange in translation. figured it out, changed the code a little bit, I did it. Can I ask You another question, example how to realize zoom in and zoom out images.
local mapW = 21216 local mapH = 17219 local sliceW = 1768 local sliceH = 1721 local sliceA = 1722 -- sliceH + 1 local map = display.newGroup() map.anchorX = 0 map.anchorY = 0 map.x = common.centerX - mapW/2 map.y = common.centerY - mapH/2 -- -- Function to only fill image if it is on screen -- local function doOnScreenFillTest( self ) local x0 = self.x + self.parent.x + self.contentWidth local x1 = self.x + self.parent.x local y0 = self.y + self.parent.y + self.contentHeight local y1 = self.y + self.parent.y local onScreen = ( x0 \>= common.left and x1 \<= common.right ) and (y0 \>= common.top and y1 \<= common.bottom ) if( onScreen and self.lastFill == "fillT.png" ) then self.fill = { type = "image", filename = self.imgPath } self.lastFill = self.imgPath --print("SHOW", self.imgPath ) elseif( not onScreen and self.lastFill == self.imgPath ) then self.fill = { type = "image", filename = "fillT.png" } self.lastFill = "fillT.png" --print("HIDE", self.imgPath ) end end -- -- Create images from slices -- local slices = {} local curX = 0 local curY = 0 for row = 1, 10 do local slice for col = 1, 12 do local imgPath = "slices/geo/BigMap\_" .. col .. "-" .. row .. ".jpg" slice = display.newImageRect( map, imgPath, sliceW, sliceH ) slice.anchorX = 0 slice.anchorY = 0 slice.x = curX slice.y = curY curX = curX + sliceW slice.imgPath = imgPath slice.lastFill = slice.imgPath slice.doOnScreenFillTest = doOnScreenFillTest slices[slice] = slice slice:doOnScreenFillTest() end curX = 0 curY = curY + sliceH sliceH = sliceA end function map:touch ( event ) for key, val in pairs (slices) do val:doOnScreenFillTest() end if event.phase == "began" then self.markX = self.x self.markY = self.y elseif event.phase == "moved" then self.x = event.x - event.xStart + self.markX self.y = event.y - event.yStart + self.markY if (self.x \< common.right - mapW) then self.x = common.right - mapW end if (self.x \> common.left) then self.x = common.left end if (self.y \< common.bottom - mapH) then self.y = common.bottom - mapH end if (self.y \> common.top) then self.y = common.top end end return true end local btnZoomIn = widget.newButton ({ id = "point\_" .. math.random( 10000 ), defaultFile = "plus.png", overFile = "plus.png", width = 100, height = 100, onPress = function () print ( "map.width: " .. map.width .. " map.height: " .. map.height) end }) btnZoomIn.x = common.right - 70 btnZoomIn.y = common.centerY map:addEventListener("touch", map ) sceneGroup:insert( map ) sceneGroup:insert( btnZoomIn )
When you change the scale, the image display function does not work correctly