Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

CBE vent gives errors when game scene reloads
Started by Painconfess Feb 08 2016 02:23 AM

7 replies to this topic
cbe dusk

Best Answer Painconfess , 12 February 2016 - 01:12 AM

 

A vent acts as a sort of particle bank. Each time you call :start(), it emits a certain number of particles for a certain amount of time. This means you have to destroy them at some point just as with most display objects:

vent:destroy()

You should destroy the vent before changing scenes.

 

- Caleb

 

 

I might have understood the vent wrong, got it working now by inserting in table the vents and use destroy function when changing scenes. 

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Painconfess

[GLOBAL: userInfoPane.html]
Painconfess
  • Enthusiast

  • 49 posts
  • Corona SDK

So I am using Dusk and CBE and I use CBE's newVent as a death animation to all enemies.

I noticed that if the death animation is used when played and player dies comes error, BUT if I complete the level and death animation has happened NO error occurs. Odd thing is that when you die/complete level the scene just reloads using composer.gotoScene("game"). So same scene removal happens on both events.

 

Here is the error:

CBE\cbe_core\vent_core\core.lua:293: attempt to call method 'insert' (a nil value)
message
stack traceback:
?: in function <?:221>
[C]: in function 'insert'
CBE\cbe_core\vent_core\core.lua:293: in function '_listener'
?: in function <?:167>
?: in function <?:221>
 

 

And  this is my deathAnimation function:

L.deathAnim = function(x,y)
local CBE = require("CBE.CBE")
    local vent = CBE.newVent({
            preset = "flame",
            positionType = "inRadius",
            color = {{0.1, 0.1, 0.1}, {0.2}, {0.3, 0.3, 0.3}},
            particleProperties = {blendMode = "add"},
            emitX = x,
            emitY = y,
 
            emissionNum = 1,
            emitDelay = 0,
            perEmit = 3,
            inTime = 100,
            lifeTime = 100,
            outTime = 600,
                    physics = {
                    velocity = 0,
                    gravityY = 0,
                    angles = {0, 360},
            },
                    onCreation = function(particle)
                    particle:changeColor({
                            --color = {0, 1, 0},
                            --time = 600
                    })
            end,
    })
    local map = (require "map").layer["ground"]
    map:insert(vent)
    vent:start()
    map=nil
end

 

 



[TOPIC: post.html]
#2

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Are you making sure to :destroy() the vent at some point?

 

- Caleb



[TOPIC: post.html]
#3

Painconfess

[GLOBAL: userInfoPane.html]
Painconfess
  • Enthusiast

  • 49 posts
  • Corona SDK

No.. I was thinking does vent remove itself when completed. Is there onComplete param for this?



[TOPIC: post.html]
#4

Painconfess

[GLOBAL: userInfoPane.html]
Painconfess
  • Enthusiast

  • 49 posts
  • Corona SDK

I tried the onEmitEnd param to destroy the vent when completed.. sadly I don't know how to destroy vent with it :D



[TOPIC: post.html]
#5

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

A vent acts as a sort of particle bank. Each time you call :start(), it emits a certain number of particles for a certain amount of time. This means you have to destroy them at some point just as with most display objects:

vent:destroy()

You should destroy the vent before changing scenes.

 

- Caleb



[TOPIC: post.html]
#6

Painconfess

[GLOBAL: userInfoPane.html]
Painconfess
  • Enthusiast

  • 49 posts
  • Corona SDK

How can I use the same vent and emit particles in multiple coordinates..? My deathAnim function now makes everytime a new vent. In this approach I need to use array for the vents to destroy them in loop before scene changes..



[TOPIC: post.html]
#7

Painconfess

[GLOBAL: userInfoPane.html]
Painconfess
  • Enthusiast

  • 49 posts
  • Corona SDK

  Best Answer

 

A vent acts as a sort of particle bank. Each time you call :start(), it emits a certain number of particles for a certain amount of time. This means you have to destroy them at some point just as with most display objects:

vent:destroy()

You should destroy the vent before changing scenes.

 

- Caleb

 

 

I might have understood the vent wrong, got it working now by inserting in table the vents and use destroy function when changing scenes. 



[TOPIC: post.html]
#8

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

 

How can I use the same vent and emit particles in multiple coordinates..?

Just set the vent's emitX and emitY properties to reposition the vent, then :start() it. If you need multiple of the same effect, a technique which has worked for me is to create two vents and use them in a round-robin fashion. You can expand this concept for three vents, four, etc., depending on how many effects you need at the same time.

 

- Caleb




[topic_controls]
[/topic_controls]