2017-03-05 50 views

回答

0

嘗試(因爲我知道你不能改變半徑所以我用xScaleyScale增加圈子)

local circle = display.newCircle( display.contentCenterX, display.contentCenterY, 50) 
step = 0.02 

local holding = false 
local function enterFrameListener() 
    if holding then 
     -- Holding button 
     circle.xScale = circle.xScale + step 
     circle.yScale = circle.yScale + step 
    else 
     -- Not holding 
     -- Code here 
    end 
end 

local function touchHandler(event) 
    if event.phase == "began" then 
     Runtime:addEventListener("enterFrame", enterFrameListener) 
     holding = true 
    elseif event.phase == "ended" or event.phase == "moved" then 
     holding = false 
     Runtime:removeEventListener("enterFrame", enterFrameListener) 
    end 
    return true 
end 

Runtime:addEventListener("touch", touchHandler) 

post代碼藉由stackoverflow.com。

+0

它不工作。我想要做的是不斷增加圓的半徑。我看到你的遊戲「Square」,這個矩形的想法與此相同。如果它在工作,你可以幫助解釋這可以如何工作? – abedulmajidalshraideh

+0

我改進了我的答案。有用。在我的第一個遊戲[THE SQUARE](https://play.google.com/store/apps/details?id=com.wordpress.ldurniat.thesquare&hl=pl)中,我使用過渡來增加廣場,但我不記得當然。 – ldurniat

+0

這是完美的。它解決了我的問題。我可以像你一樣獲得這些知識。 – abedulmajidalshraideh

相關問題