Change properties from scene objects on screen

Hi Guys,

Sorry if this is a stupid question, but could you please let me know how can I change the property from an object loaded on the screen that is part of the composer current scene view group?

I want to execute the changes from an external module not from the scene itself. For example change the alpha from an image loaded by the scene.

How do I access this object to change its alpha property?

What is the syntax / method?

Thanks for the help.

The simplest way is to use Composer’s getVariable and setVariable APIs. These let you create a key-value pair. Lets assume the object you want is called “box”. In your scene where the object exists you could do:

local box = display.newRect( 100, 100, 50, 50) composer.setVariable("box", box)

Now in your other module, you would need to require composer:

local composer = require("composer") local box = composer.getVariable("box") box.alpha = 0.5

Rob

Rob,

Thanks for the quick reply!

It worked just as I wanted. Excellent!

The simplest way is to use Composer’s getVariable and setVariable APIs. These let you create a key-value pair. Lets assume the object you want is called “box”. In your scene where the object exists you could do:

local box = display.newRect( 100, 100, 50, 50) composer.setVariable("box", box)

Now in your other module, you would need to require composer:

local composer = require("composer") local box = composer.getVariable("box") box.alpha = 0.5

Rob

Rob,

Thanks for the quick reply!

It worked just as I wanted. Excellent!