Books In Director 1.4 - Doesn't Work When I Try To Copy

hello there,

i have downloaded the books example files from this page:

http://rauberlabs.blogspot.com/2011/08/director-14-books.html

however, when i tried to copy the same pages to be included in my “how to play” page, it just doesnt want to work. Basically i just rename the file main.lua in books folder to be howto.lua and i just copy + paste the entire files to my game folder. What I did then put director:changeScene (“howto”) for the button in my main menu

I wonder why it doesnt work? It doesn’t return any error in debugging mode, just blank screen

Dont tell me im lazy or something, i just want to test-trial if this works because i want to do exactly the same thing for my “how to play” page (slideshow from different pictures). Anyone can enlighten me? Thanks. [import]uid: 114765 topic_id: 23982 reply_id: 323982[/import]

Are you saying that you no longer have a file named main.lua in your project?

You must always have a main.lua. That’s the file CoronaSDK is going to look for first when you start your app. [import]uid: 67839 topic_id: 23982 reply_id: 96649[/import]

I do have main.lua. It’s hard to explain it here but basically it’s like this in director books:

main. lua -> intro.lua

right?

while in my game it SHOULD BE like this:

main. lua -> menu.lua -> howto.lua -> intro.lua

the howto.lua IN MY GAME = main.lua IN DIRECTOR BOOKS

so do i have main.lua? Yes.
Is it different from main.lua in director books? Yes of course.
so where’s the main.lua of director books in your game? It’s howto.lua

where’s the error? When i click the “how to” button in menu page in corona simulator (which it should redirect to howto.lua) [import]uid: 114765 topic_id: 23982 reply_id: 96758[/import]

I don’t know if anyone can fully understand what you’re doing without seeing your code.

In your main.lua, do you have a line like this?

director:changeScene ( “menu” )

In your menu.lua, howto.lua and intro.lua do you have a function named new()?

If you look at the main.lua that came with the director book example, you will see a table named pageList. This is a table of images that make up the book. Do you have this in your main.lua?

[import]uid: 67839 topic_id: 23982 reply_id: 96797[/import]

hey there, now I see the problem. The pagelist needs to be in main.lua no matter what. Now it works! [import]uid: 114765 topic_id: 23982 reply_id: 96832[/import]

hey there i have a new question…

how do i “add” a button in the pages slideshow? I want to add a button where i want to put director.changeScene at the end of the slideshow, how to do that? [import]uid: 114765 topic_id: 23982 reply_id: 96844[/import]

Yes, you need to have the pagelist located in the main.lua file

I have been trying to do that myself. It is simple to add the button, like so and the event listener, but it crashes.

in pages.lua

  
//button image  
  
local button\_home = display.newImageRect("res/images/button\_home.png", 53, 53);  
 button\_home:setReferencePoint(display.CenterReferencePoint);  
 button\_home.x = 50; button\_home.y = 30;  
 button\_home.scene = "menu";  
 localGroup:insert(button\_home);  
  
//listener function  
 function changeScene(e)  
 if(e.phase == "ended") then  
 director:changeScene( (e.target.scene, "crossfade" );  
 end  
 end  
  
//bind the listener to button  
button\_home:addEventListener("touch", changeScene);  

Again, that is what i have, but the director:changeScene crashes things. You can use the other function to go to any page, but you cannot leave the book. Hope this gives you a start, from here, i guess its just trial and error for us until we find the code to change back to the main menu scene.

Updated…

Here is the working code

  
//button image  
  
local button\_home = display.newImageRect("res/images/button\_home.png", 53, 53);  
 button\_home:setReferencePoint(display.CenterReferencePoint);  
 button\_home.x = 50; button\_home.y = 30;  
 button\_home.scene = "menu";  
 localGroup:insert(button\_home);  
  
//listener function  
 function changeScene(e)  
 if(e.phase == "ended") then  
 director:turnToScenes()  
  
 --director:changeScene("menu", "crossfade" ); -- Back to Menu  
 director:changeScene(e.target.scene, "crossfade" ); -- Button\_Defined Scene  
 -- Just uncomment which one you want to use  
 end   
 end  
  
//bind the listener to button  
button\_home:addEventListener("touch", changeScene);  
  

Hope this helps! [import]uid: 75514 topic_id: 23982 reply_id: 96956[/import]

thanks mate, it works! [import]uid: 114765 topic_id: 23982 reply_id: 97094[/import]