2016-07-02 14 views
0

Corona SDKでParticle Systemsを使用する方法を理解しようとしています。 私はそれを読もうとしましたが、エミッタまで届いていましたが、そこから立ち往生しました。 Particle Systemとエミッタをどのように接続しますか?動作しませんでした。この後のようCorona SDKでParticle Systemsを正しく使用する方法

function NewTrail() 
ParticleSystem:createParticle(
    { 
     flags = { "wall" }, 
     x = display.contentCenterX, 
     y = display.contentCenterY, 
     velocityX = 100, 
     velocityY = 0, 
     color = { 0, 0, 1, 1 }, 
     lifetime = 32.0 
    } 
) 
end 
timer.performWithDelay(100, NewTrail, -1) 

-----------------------emitter--------------------------- 

local emitterParams = { 
    textureFileName = "particle.png", 
} 
local emitter = display.newEmitter(emitterParams) 

オーケー私は多分パーティクルシステムを考えて、エミッタが、私はこれを試してみましたように、2つの異なるものです:

local emitterParams = { 
    textureFileName = "images/particle.png", 
    duration = -1, 
    speed = 100, 
    particleLifespan = 5, 
    maxParticles = 20, 
    angle = 180, 
    startParticleSize = 10, 
    finishParticleSize = 0, 
} 
local Trail = display.newEmitter(emitterParams) 
Trail:start() 

そして、それはまだ動作しませんでした。どんな入力?

答えて

0

これでわかりました。私はまだエミッタを理解していないので、もし誰かが助けたいと思っていたらどうぞ。

local physics = require("physics") 
physics.start() 

してから実行してパーティクルシステムを初期化します:

local testParticleSystem = physics.newParticleSystem(
    { 
    filename = "images/particle.png", 
    radius = 3, 
    imageRadius = 4 
    } 
) 

を最後に、あなたが行われている実際の粒子を作成するためにしているパーティクルシステムを取得するには、あなたがしている最初の物理学を開始する必要が動作するようにように:

local function onTimer(event) 

    testParticleSystem:createParticle(
     { 
     flags = "water", 
     velocityX = 256, 
     velocityY = 480, 
     color = { 1, 0, 0.1, 1 }, 
     x = 0, 
     y = 0, 
     lifetime = 32.0 
     } 
    ) 
    end 

timer.performWithDelay(20, onTimer, 0) 
関連する問題