【问题标题】:Corona: How to scale an Image after I created itCorona:创建图像后如何缩放图像
【发布时间】:2016-07-31 14:31:26
【问题描述】:

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

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

但是我该怎么做呢?

【问题讨论】:

    标签: image lua scale coronasdk


    【解决方案1】:

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

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

    【讨论】:

    • 天哪,我太傻了,我总是使用 : 而不是 . .谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-11-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-22
    相关资源
    最近更新 更多