Using director within another project

Hi everyone,

I’m trying to incorporate the list view 2 project from the sample code. I used director to pretty transition to that scrolling list view. On that list view I added a button and I want it to transition back to my original screen (individual.lua). I’m having trouble figuring out how to implement this. Here is the code so far, Yes I was fooling around with it so much it is a hot mess right now:

function resetBtnRelease( event )  
  
 -- Create back button in top bar  
--[[ local bt01 = display.newImage("images/backButton.png")  
 local function bt01t ( event )  
 if event.phase == "ended" then]]--  
 director:changeScene("individual","moveFromLeft")  
 --[[end  
 end  
 bt01:addEventListener("touch",bt01t)  
 bt01.x = 35  
 bt01.y = 21]]--  
 localGroup:insert(bt01)  
 return localGroup  
end  

I create the button using this code:

resetBtn = ui.newButton{   
 default = "Default.png",   
 over = "Default.png",   
 onRelease = resetBtnRelease  
}  

My question is, how do I use the button from the list view 2 project to return back to my original screen called individual.lua? I know director needs to return a value but I’m not sure where to situate this. Can anyone help? Again excuse the code and the commenting but I’m pretty lost on how to do this. Thanks. [import]uid: 31262 topic_id: 6781 reply_id: 306781[/import]

OK I think I explained this poorly.

I have menus using the director class. One of the buttons calls a scrolling list view (the scrolling list view 2 project). This project does not use the director class. I added a back button on this list view. How do I use this button to return to the old screen I was on? I have only been working with director so I don’t know how to navigate screens without it. [import]uid: 31262 topic_id: 6781 reply_id: 23732[/import]

I’m pretty new to using director class but I think you might be better off either using it for everything or not at all. You code is a little confusing, you might want to open up the sample app included with the director class and use screen2.lua as a basis for for any screen you go to from your main menu. Doing that really helps me keep things organized and I don’t end up doing the little things that make director work well (cleaning up on exit, returning that localGroup at the right time). But that’s if you are going to use director class for all screen movements.

However, if you just want to know how to move from screen to screen without using director class. You should try creating a group for each screen (all in the same .lua file), inserting everything you want into each group and then using transition.to() or transition.from() (transition.to is a bit less confusing).

When you first create the screen that your listView will bring in, set it’s location x value at display.viewableContentWidth (so that it’s offscreen to the right). Then when you use the code below, it will come in from that position to the center position.

Here’s an example from a buttonRelease function on a mainMenu:
I hope this helps.

[lua]//moving main menu offscreen and audioDetailScreen onscreen
transition.to(mainMenu, {time=400, x=display.viewableContentWidth*-1, transition=easing.outExpo })
transition.to(audioDetailScreen, {time=400, x=0, transition=easing.outExpo , alpha = 1})
[import]uid: 12578 topic_id: 6781 reply_id: 24270[/import]

OK Matthew I followed your advice and I re-wrote it and used only director and I figured out how to do this. I have a different issue with the dragable list view covering up my button but I will open a new thread for this. Thanks for the guidance! [import]uid: 31262 topic_id: 6781 reply_id: 24516[/import]