如何在Corona中将图像附加到另一个图像?

时间:2016-07-10 00:11:06

标签: corona

我想将图像附加到另一个图像的一侧,以便当其中一个图像被移动或发生变化(大多数移动)时,另一个图像将保留在第一个图像的一侧。

1 个答案:

答案 0 :(得分:1)

有几种方法可以做到这一点:

只需制作一张图片:

-- first, create the image sheet object
local options =
{
    -- The params below are required

    width = 70,
    height = 41,
    numFrames = 2,

    -- The params below are optional (used for dynamic image sheet selection)

    sheetContentWidth = 70,  -- width of original 1x size of entire sheet
    sheetContentHeight = 82  -- height of original 1x size of entire sheet
}

local imageSheet = graphics.newImageSheet( "fishies.png", options )

local myImage = display.newImage( imageSheet, 1 )

如果你有很多这样的话,你可以组成一个显示组:

local myImage = display.newImage( "image.png" )
local myImage2 = display.newImage( "image2.png" )

local group = display.newGroup()
group:insert( myImage )
group:insert( myImage2 )

一个简单的方法也就是使第一个图像移动的任何东西,编码它以便移动第二个图像:

image1.x = 567
image2.x = 567+offset
相关问题