Pulling Sprites from another module

Here is my first page:
[lua]module(…, package.seeall)

–Change Scene Required For Switching Pages
–Start Scene
function new()
local Scene = display.newGroup();

–Document Settings
local _W = display.contentWidth
local _H = display.contentHeight

–List of sprites
function Light_Blue(params);
R1 = sprite.newSpriteSheet( “sprites/LightBlue_Row1.png”, 480, 854 )
R1:play()

R2 = sprite.newSpriteSheet( “sprites/LightBlue_Row2.png”, 480, 854 )
R2:play()

R3 = sprite.newSpriteSheet( “sprites/LightBlue_Row3.png”, 480, 854 )
R3:play()

R4 = sprite.newSpriteSheet( “sprites/LightBlue_Row4.png”, 480, 854 )
R4:play()
end
–End of list

–Assets for Scene Group
–*must return all assets whether they are in the group or not*
Scene:insert(R1);
Scene:insert(R2);
Scene:insert(R3);
Scene:insert(R4);
Scene:insert(Light_Blue);

–Event Listeners for Scene Group
return Scene;
end
–End Scene Group[/lua]

All I’m doing is calling the sprites and then telling them to play within 1 function.

Here’s my main page:

[lua]module(…, package.seeall)

–Change Scene Required For Switching Pages
–Start Scene
function new()
local Scene = display.newGroup();

–Document Settings
local _W = display.contentWidth
local _H = display.contentHeight
local background = display.newImage(“Renders/Levels/Level_1.png”)

local Game_Pieces = require(Game_Pieces);

local 1st_Level = Game_Pieces.Light_Blue

–Assets for Scene Group
–*must return all assets whether they are in the group or not*
Scene:insert(background);
Scene:insert(1st_Level);

–Event Listeners for Scene Group

return Scene;
end
–End Scene Group[/lua]

I’m new. How do I load all my sprites into 1 module. Tell them to play together and at random. Then load that information into another module? This code is just to play it but it doesn’t seem to work. What am I doing wrong? [import]uid: 77916 topic_id: 12887 reply_id: 312887[/import]

There are a couple of problems… First…

Game_Pieces.Light_Blue is a function, so when you do:

local 1st_Level = Game_Pieces.Light_Blue

1st_Level is basically a pointer to a function.

I think what you want is:

local 1st_Level = Game_Pieces.Light_Blue()

note the parens. It’s a minor code difference but it makes all the difference. Now, Game_Pieces.Light_Blue() will be called as a function and whatever that function returns will be put into 1st_level. Without the parens, the reference to the function gets put in.

Now the 2nd problem is the function Light_Blue doesn’t return anything. So either you should create a local display group inside of that function and stick the variables you create into that display group and then do a return on it… or…

In Game_Pieces.new() right before you start adding all the R1’s into scene, call Light_Blue() and stick the results of Game_Pieces.new() into your variable:

[lua]module(…, package.seeall)

–Change Scene Required For Switching Pages
–Start Scene
function new()
local Scene = display.newGroup();

–Document Settings
local _W = display.contentWidth
local _H = display.contentHeight

–List of sprites
function Light_Blue(params);
R1 = sprite.newSpriteSheet( “sprites/LightBlue_Row1.png”, 480, 854 )
R1:play()

R2 = sprite.newSpriteSheet( “sprites/LightBlue_Row2.png”, 480, 854 )
R2:play()

R3 = sprite.newSpriteSheet( “sprites/LightBlue_Row3.png”, 480, 854 )
R3:play()

R4 = sprite.newSpriteSheet( “sprites/LightBlue_Row4.png”, 480, 854 )
R4:play()
end
–End of list

– NOTE THIS ADDITION
Light_Blue();
– ******************

–Assets for Scene Group
–*must return all assets whether they are in the group or not*
Scene:insert(R1);
Scene:insert(R2);
Scene:insert(R3);
Scene:insert(R4);
Scene:insert(Light_Blue);

–Event Listeners for Scene Group
return Scene;
end
–End Scene Group[/lua]

then

[lua]module(…, package.seeall)

–Change Scene Required For Switching Pages
–Start Scene
function new()
local Scene = display.newGroup();

–Document Settings
local _W = display.contentWidth
local _H = display.contentHeight
local background = display.newImage(“Renders/Levels/Level_1.png”)

local Game_Pieces = require(Game_Pieces);

– NOTICE CHANGE
local 1st_Level = Game_Pieces.new()
– *************

–Assets for Scene Group
–*must return all assets whether they are in the group or not*
Scene:insert(background);
Scene:insert(1st_Level);

–Event Listeners for Scene Group

return Scene;
end
–End Scene Grou[/lua]

Give that a try… [import]uid: 19626 topic_id: 12887 reply_id: 47318[/import]

thanks!!! I know this will come to me easier as I go along. You helped me a lot!!! [import]uid: 77916 topic_id: 12887 reply_id: 47356[/import]