I have some problems trying to work with both director class and particle candy. Assuming I have a main page and some screens.lua. My folder organisation is :
mainfolder/lib_particle_candy.lua
mainfolder/main.lua (changing scene to home.lua)
mainfolder/screens/home.lua (navigation screen reaching screen1.lua)
mainfolder/screens/screen1.lua
If I want to run PC in one screen only :
-
where to put ?
local Particles = require("../lib\_particle\_candy")
in main.lua, in screen1.lua -
what
localGroup:insert()
Example :
Taking your Sample_Fading code, should it be :
module(..., package.seeall)
-- Main function - MUST return a display.newGroup()
function new()
local localGroup = display.newGroup()
------ Your code here ------
-- LOAD PARTICLE LIB
local Particles = require("../lib\_particle\_candy") -- HERE ?
local screenW = display.contentWidth
local screenH = display.contentHeight
local StatusText = display.newText( "", screenW/2, screenH-20, "Verdana-Bold", 12 )
StatusText:setTextColor( 255,255,255 )
-- DIRECTOR
localGroup:insert(StatusText)
-- CREATE AN EMITTER (NAME, SCREENW, SCREENH, ROTATION, ISVISIBLE, LOOP)
Particles.CreateEmitter("E1", screenW\*0.1, screenH\*0.8, 90, true, true)
-- DEFINE PARTICLE TYPE PROPERTIES
local Properties = {}
Properties.imagePath = "images/arrow.png"
Properties.imageWidth = 32 -- PARTICLE IMAGE WIDTH (newImageRect)
Properties.imageHeight = 32 -- PARTICLE IMAGE HEIGHT (newImageRect)
Properties.velocityStart = 150 -- PIXELS PER SECOND
Properties.autoOrientation = true -- ROTATE TO MOVEMENT DIRECTION
Properties.killOutsideScreen = true -- PARENT LAYER MUST NOT BE NESTED OR ROTATED!
Properties.lifeTime = 3000 -- MAX. LIFETIME OF A PARTICLE
Properties.alphaStart = 0 -- PARTICLE START ALPHA
Properties.fadeInSpeed = 0.5 -- PER SECOND
Properties.fadeOutSpeed = -0.75 -- PER SECOND
Properties.fadeOutDelay = 1500 -- WHEN TO START FADE-OUT
Particles.CreateParticleType ("Test1", Properties)
-- FEED EMITTERS (EMITTER NAME, PARTICLE TYPE NAME, EMISSION RATE, DURATION, DELAY)
Particles.AttachParticleType("E1", "Test1", 5, 99999,0)
-- DIRECTOR
localGroup:insert(E1) -- NOT SURE
localGroup:insert(Test1) -- NOT SURE
-- TRIGGER THE EMITTERS
Particles.StartEmitter("E1")
----------------------------------------------------------------
-- MAIN LOOP
----------------------------------------------------------------
local function main( event )
-- UPDATE PARTICLES
Particles.Update()
-- DISPLAY PARTICLE COUNT
StatusText.text = "PARTICLES:"..Particles.CountParticles()
end
-- timer.performWithDelay( 33, main, 0 )
Runtime:addEventListener( "enterFrame", main )
----------------------------------------------------------------
-- END OF SAMPLE CODE
----------------------------------------------------------------
------ Home ------
local bt01 = display.newRect( 0, 10, 320, 20 )
bt01:setFillColor( 100,100,100 )
localGroup:insert(bt01)
local label1 = display.newText("HOME", 0, 0, native.systemFontBold, 16)
label1:setTextColor( 255,255,255)
label1.x = 160
label1.y = 20
localGroup:insert(label1)
local function bt01t ( event )
if event.phase == "ended" then
----- Candy clean up before changing scene -----
CleanUp()
----- Director -----
director:changeScene("samples/home","fade", "black")
end
end
bt01:addEventListener("touch",bt01t)
-- MUST return a display.newGroup()
return localGroup
end
Thx !
[import]uid: 9328 topic_id: 6123 reply_id: 306123[/import]