[suggestion] Composer.addDisplayToCurrentScene

Hey Corona Team :slight_smile:

I use this function very often maybe there is a better way or there is already a function to do this ?

My suggestion is to add this function to the composer. 

function addDisplayToCurrentScene(displayObj) local Scene = composer.getScene(composer.getSceneName( "current" )) Scene.view:insert(displayObj) end

Well normally in one of the event scenes, like scene:create() or scene:show() you have access to the view via the sceneGroup variable.  The first line in our templates does"

 local sceneGroup = self.view

Then you just do:

sceneGroup:insert( displayObject )

Outside of those event functions you would just do:

scene.view:insert( displayObject )

No real need to provide a function for this.

Rob

But what if i create an displayObject inside another Object. For example inside the constructor of an Enemy ? or is it bad taste ? 

function enemy.new() newEnemy = {} setmetatable(...) newEnemy.grafic = display.new(...) return newEnemy end

Pass the group to the constructor of the object.

Rob

Well normally in one of the event scenes, like scene:create() or scene:show() you have access to the view via the sceneGroup variable.  The first line in our templates does"

 local sceneGroup = self.view

Then you just do:

sceneGroup:insert( displayObject )

Outside of those event functions you would just do:

scene.view:insert( displayObject )

No real need to provide a function for this.

Rob

But what if i create an displayObject inside another Object. For example inside the constructor of an Enemy ? or is it bad taste ? 

function enemy.new() newEnemy = {} setmetatable(...) newEnemy.grafic = display.new(...) return newEnemy end

Pass the group to the constructor of the object.

Rob