Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fork of Ricardo Rauber's Director class for Corona SDK
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.


Director Class

This is a fork of the Director class created by Ricardo Rauber for Ansca’s Corona SDK. It includes useful extensions developed by Josh Tynjala. This fork is currently based on version 1.2.

Dependency injection with addParamsForModule()

The addParamsForModule() function allows the Director class to pass a parameters object to a module’s new() function when changing scenes. Rather than polluting the global namespace, you can use this function to inject data into screens when Director displays them.

local settingsData = { soundsEnabled = true }
director:addParamsForModule("settings", settingsData)
director:addParamsForModule("game", settingsData)
director:changeScene("settings", "moveFromLeft")

In the code above, both the settings screen and the game itself can share the same object for settings data, and they can access it without using a global variable.

Using Director’s scene template as a basis, here’s how you might access the parameters that are passed to new():

module(..., package.seeall)
local localGroup = display.newGroup()
function new(params)

	if params.soundsEnabled then
		-- do something

	------ More code here ------

	return localGroup

Custom Effects

This version of Director includes support for custom effects. Rather than being limited to “moveFromRight”, “fade”, “flip”, or any of the other effects built into Director, you can pass in your own effect implementations.

module(..., package.seeall)

function new(params)
	local currView = params.currView
	local nextView = params.nextView
	local time = params.time
	nextView.x = display.contentWidth
	nextView.y = 0 ( currView, { x=display.contentWidth*-1, time=time } ) nextView, { x=0, time=time } )

The code above is a reimplementation of the "moveFromRight" effect. Custom effects receive three parameters when new() is called: currView, nextView, and time.

Using a custom effect is not much different than using a built-in effect. Instead of passing in a string, you should pass in a reference to the module.

local CustomMoveFromRight = require("CustomMoveFromRight")
director:changeScene("settings", CustomMoveFromRight)

The code above demonstrates how to use the custom implementation of "moveFromRight" that we created earlier.

Something went wrong with that request. Please try again.