Corona:创建图像后如何缩放图像

时间:2016-04-10 15:22:54

标签: image lua scale corona

我在这里创建了一个图片:

gangster = display.newImageRect("assets/gangsta.png", gangsterwidth, gangsterheight)
gangster.x = display.contentCenterX
gangster.y = 950
sceneGroup:insert(gangster)

我想在此处设置后立即缩放图像:

local function enterFrameListener()
    if holding then
       if ( touchx < gangster.x) then
          gangster.x = gangster.x - 10

        end
           if ( touchx > gangster.x) then
          gangster.x = gangster.x + 10

        end
               if ( touchy > gangster.y) then
          gangster.y = gangster.y + 10
          -- INCREASE HEIGHT AND WIDTHHERE

        end
               if ( touchy < gangster.y) then
          gangster.y = gangster.y - 10
           gangsterheight = gangsterheight -5
          -- DECREASE HEIGHT AND WIDTH HERE

        end
         if (touchx == gangster.x) then
          if (touchy == gangster.y) then
         Runtime:removeEventListener( "enterFrame", enterFrameListener)
         holding = false
         end
       end
    else
    end
end

但我该怎么做?

1 个答案:

答案 0 :(得分:2)

显示对象具有缩放方法。在你的情况下,你应该能够做到

gangster:scale(0.5,0.5) -- half the size