1

こんにちは、何らかの理由でローカルヘリコプター= display.newImage( "helicopter.png") を雲の前に表示することができません(背景を移動)、この問題を解決する良い方法はありますか?

<code>
function initcloud()
    local cloud1 = {}
    cloud1.imgpath = "cloud1.png"; --Set Image Path for cloud
    cloud1.movementSpeed = 10000; --Determines the movement speed of cloud
    table.insert(cloudTable, cloud1); --Insert cloud into cloudTable

    local cloud2 = {}
    cloud2.imgpath = "cloud2.png";
    cloud2.movementSpeed = 12000;
    table.insert(cloudTable, cloud2);               

    local cloud3 = {}
    cloud3.imgpath = "cloud3.png";
    cloud3.movementSpeed = 14000;
    table.insert(cloudTable, cloud3);
end --END initcloud()   

function getRandomcloud()
local temp = cloudTable[math.random(1, #cloudTable)] -- Get a random cloud from cloudTable
local randomcloud = display.newImage(temp.imgpath); --physics.addBody(randomcloud, {isSensor = true});
randomcloud.myName = "cloud";
randomcloud.movementSpeed = temp.movementSpeed; -- set the cloud cloudting point
randomcloud.x = math.random(10, _W);
randomcloud.y = -35;
randomcloud.rotation = math.random(0, 20); -- move the cloud
cloudMove = transition.to(randomcloud, {
time = randomcloud.movementSpeed, 
y = 500,
onComplete = function(self)
self.parent:remove(self);
self = nil;
end 
});
end

function cloudtGame()
    cloudTimer1 = timer.performWithDelay(1400,getRandomcloud, 0)
    cloudTimer2 = timer.performWithDelay(2000,getRandomcloud, 0)
    cloudTimer3 = timer.performWithDelay(2400,getRandomcloud, 0)        
end--END cloudtGame()

initcloud()
cloudtGame()

local helicopter = display.newImage("helicopter.png")
</code>

ありがとうございました

4

2 に答える 2

1

私のソリューションであなたのコードを実行したところ、うまくいきました。私が追加したのは次のとおりです。

randomcloud:toBack()

randomcloudは展示品なので、ページの一番後ろに送れます。

于 2013-05-16T03:57:21.500 に答える
0

最も簡単な解決策は、2 つの DisplayGroup (雲用とヘリコプター用) を 1 つの「ルート」グループ内に適切な順序で使用することです。そうすれば、グループのないオブジェクトは 1 つだけになります - 「ルート」。

http://www.coronalabs.com/blog/2012/02/28/corona-display-groups-101/

于 2013-02-21T16:18:33.803 に答える