Corona:创建图像后如何缩放图像
Corona: How to scale an Image after I created it
我在这里创建了一个图像:
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
但是我该怎么做呢?
显示对象有缩放方法。在你的情况下,你应该能够做到
gangster:scale(0.5,0.5) -- half the size
我在这里创建了一个图像:
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
但是我该怎么做呢?
显示对象有缩放方法。在你的情况下,你应该能够做到
gangster:scale(0.5,0.5) -- half the size