Bug in sample code

Hi

I've been looking at the samples in the latest release and found an error in Sample_Physics_Using_FX_Fields. Here is the terminal output.

--> PARTICLE SYSTEM READY. LET'S ROCK.
--> Particles.CreateEmitter(): ADDED EMITTER 'E1'
--> Particles.CreateParticleType(): CREATED PARTICLE TYPE 'BoxParticles'.
--> Particles.CreateParticleType(): CREATED PARTICLE TYPE 'BallParticles'.
--> Particles.AddParticleType(): ADDED PARTICLE TYPE 'BoxParticles' TO EMITTER 'E1'.
--> Particles.AddParticleType(): ADDED PARTICLE TYPE 'BallParticles' TO EMITTER 'E1'.
--> Particles.StartEmitter(): EMITTER 'E1' STARTED.
--> Particles.CreateFxField(): ADDED FX FIELD 'A1'
Runtime error
..._CoronaSDK-3/Sample_Physics_Using_FX_Fields/main.lua:69: attempt to call method 'setFillColor' (a nil value)
stack traceback:
[C]: in function 'setFillColor'
..._CoronaSDK-3/Sample_Physics_Using_FX_Fields/main.lua:69: in main chunk
Runtime error: ..._CoronaSDK-3/Sample_Physics_Using_FX_Fields/main.lua:69: attempt to call method 'setFillColor' (a nil value)
stack traceback:
[C]: in function 'setFillColor'
..._CoronaSDK-3/Sample_Physics_Using_FX_Fields/main.lua:69: in main chunk

Here is the offending line of code

1
2
3
4
5
Particles.CreateFXField("A1", 1, screenW*0.1,screenH*0.25, 10, 120, true)
local Field1 = Particles.GetFXField("A1")
Field1:setFillColor   (255,0,0, 46)  -- this line causes the error
Field1:setStrokeColor (255,0,0)
</code

Thanks for the hint. The internal structure of FX Fields changed a bit in the last release, so the FillColor and Stroke commands cannot be applied to fields directly anymore. But that's no problem, just remove those lines from the sample code. They just applied another color to the FX Field.

An updated version of this sample will be included with the next release.

views:1660 update:2011/10/14 9:11:21
corona forums © 2003-2011