Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Director class - check this out!
Started by ricardorauber Oct 06 2010 03:20 AM

- - - - -
79 replies to this topic
[TOPIC CONTROLS]
Page 3 of 4 1 2 3 4
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#51

dweezil

[GLOBAL: userInfoPane.html]
dweezil
  • Contributor

  • 568 posts
  • Corona SDK

Also tried the

package.loaded[lastScene].clean()

and added an empty clean function to each screen but transitioning from screens doesn't work
uid: 9371 topic_id: 2447 reply_id: 11753


[TOPIC: post.html]
#52

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

dweezil

First let me answer your question about which listeners to clear. If you take a look at the asnca roadmap, you'll find that corona will have a table of active timers. That was one of the issues that I created and with that, Director will clean all active timers. Today, Director can only clean display objects and their listeners, so you have to clean Runtime listeners and timers.

Now let's talk about the logic of the Director class. It's very simple, I created it because before it corona didn't have any kind of changing control for multiple files, all development were 90% in the main.lua file. The idea was to build something that makes possible to use different files for different levels for a game. So, it was build thinking on cleanning everything of the old screen and adding all of the new screen. Director's changeScene tests if is the same screen, then choose the effect and start to clean all objects inserted in the view. After that, it loads the new file and do the garbage collect to clean memory.

About the package.loaded[lastScene].clean(), any error could stop the transitions. For that, the best to do is take the errors and make a debug (maybe using the print() function) or you can put it here and we try to help you.
uid: 8556 topic_id: 2447 reply_id: 11755


[TOPIC: post.html]
#53

dweezil

[GLOBAL: userInfoPane.html]
dweezil
  • Contributor

  • 568 posts
  • Corona SDK

It might have helped if I had declared the clean function without the local keyword! DOH!!!
uid: 9371 topic_id: 2447 reply_id: 11756


[TOPIC: post.html]
#54

dweezil

[GLOBAL: userInfoPane.html]
dweezil
  • Contributor

  • 568 posts
  • Corona SDK

Next problem. Now I've added...

local function crossBar(event)
print("crossBar()")
end

timer.performWithDelay(1000, crossBar, 0)

...to my game screen but the screen now scrolls off the screen during the transition. Any ideas why?
uid: 9371 topic_id: 2447 reply_id: 11757


[TOPIC: post.html]
#55

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

Your timer will print "crossBar()" forever with that. You have to create a variable to control it and cancel the timer while changing the scene.

Something like this:

local function crossBar(event)
  if sceneChanged then
    timer.cancel(self)
  else
    print("crossBar()")
  end
end
timer.performWithDelay(1000, crossBar, 0)
uid: 8556 topic_id: 2447 reply_id: 11758


[TOPIC: post.html]
#56

dweezil

[GLOBAL: userInfoPane.html]
dweezil
  • Contributor

  • 568 posts
  • Corona SDK

Where is sceneChanged defined?
uid: 9371 topic_id: 2447 reply_id: 11759


[TOPIC: post.html]
#57

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

You can put it at the beginning of your file an use all over it.
uid: 8556 topic_id: 2447 reply_id: 11760


[TOPIC: post.html]
#58

dweezil

[GLOBAL: userInfoPane.html]
dweezil
  • Contributor

  • 568 posts
  • Corona SDK

In the main.lua?

Could you show me some code?

I still don't quite understand why it would cause the images would be scrolled off the screen.

What I'm trying to achieve is to move a game object after 20 seconds of time.
uid: 9371 topic_id: 2447 reply_id: 11761


[TOPIC: post.html]
#59

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

dweezil

Maybe you are not looking for the code that's doing what you are talking about. It will be much easier if you put your code here.
uid: 8556 topic_id: 2447 reply_id: 11762


[TOPIC: post.html]
#60

dweezil

[GLOBAL: userInfoPane.html]
dweezil
  • Contributor

  • 568 posts
  • Corona SDK

Can I email you the source?
uid: 9371 topic_id: 2447 reply_id: 11763


[TOPIC: post.html]
#61

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

sure
uid: 8556 topic_id: 2447 reply_id: 11765


[TOPIC: post.html]
#62

Akenaten

[GLOBAL: userInfoPane.html]
Akenaten
  • Observer

  • 14 posts
  • Guests

Hi Ricardo,

Can you tell me how I would initiate a resume on exit function with Director? How would it be written and would it have to be on each .lua file or in the build settings? Thanks.
uid: 10083 topic_id: 2447 reply_id: 11815


[TOPIC: post.html]
#63

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

Akenaten,

It depends on how your app is. Some apps just need to go back to a simple screen and others have a lot of things happening at the same time. I think that the best way to do it is using the SQLite or some file to store the variables and when it resume just query the information and build it again.
uid: 8556 topic_id: 2447 reply_id: 12713


[TOPIC: post.html]
#64

izzthetruth

[GLOBAL: userInfoPane.html]
izzthetruth
  • Enthusiast

  • 91 posts
  • Guests

this works for me the only problem is, when i load my scene1 (which is the 1st level in my game), i play my game, but if i click anywhere on the screen, it changes the scene to another one. how can i stop that from happening? i want it to change to scene1 then stay there no matter where i click
uid: 10827 topic_id: 2447 reply_id: 13079


[TOPIC: post.html]
#65

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

izzthetruth

Take a look at your code, I think you putted the changeScene in the background object, so wherever you touch it will change.
uid: 8556 topic_id: 2447 reply_id: 13107


[TOPIC: post.html]
#66

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

Video Tutorial: http://rauberlabs.blogspot.com/2010/12/director-video-tutorial.html
uid: 8556 topic_id: 2447 reply_id: 13799


[TOPIC: post.html]
#67

iWalter

[GLOBAL: userInfoPane.html]
iWalter
  • Enthusiast

  • 46 posts
  • Corona SDK

Hi ricardo...thanks for the great work and awesome class!

I am new to Corona.

What is the difference between changescene() and loadscene()?

I am trying to create a slideshow app with 20 images where each image will transition to another image until all images have been displayed. What is the best approach? I am using
changescene() to load the images. The 1st screen/image displays fine; however, I can't get the 2nd screen with the image to display.

Thanks again!
uid: 9936 topic_id: 2447 reply_id: 13993


[TOPIC: post.html]
#68

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

@iWalter

Thanks a lot!

loadScene only open the file and loads it to the memory while changeScene does everything else like positioning views in the right place, making the transitions, calls loadScene and clean up memory. Please never use loadScene directly, use changeScene and all will be fine.

What kind of event you are using to call the next file?
uid: 8556 topic_id: 2447 reply_id: 13996


[TOPIC: post.html]
#69

iWalter

[GLOBAL: userInfoPane.html]
iWalter
  • Enthusiast

  • 46 posts
  • Corona SDK

Wow! Thx for that fast reply.

That is probably the problem. I am not using any kind of event. I just figured that when screen 1 loads it will automatically call screen 2 with the changescreen() function, and then screen 2 will call screen 3, etc, etc.

Is there some type of page load event like there is in the web world?
uid: 9936 topic_id: 2447 reply_id: 13997


[TOPIC: post.html]
#70

iWalter

[GLOBAL: userInfoPane.html]
iWalter
  • Enthusiast

  • 46 posts
  • Corona SDK

I probably need to use the enterframe event. Is that what you would recommend?

Thx!
uid: 9936 topic_id: 2447 reply_id: 14002


[TOPIC: post.html]
#71

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

@iWalter

The best thing to do is use it in a touch event listener.
uid: 8556 topic_id: 2447 reply_id: 14006


[TOPIC: post.html]
#72

iWalter

[GLOBAL: userInfoPane.html]
iWalter
  • Enthusiast

  • 46 posts
  • Corona SDK

@ricardorauber

There is no touching involved. It is an automated slideshow. Once you start the app, each image will transition to the next image without any user input.
uid: 9936 topic_id: 2447 reply_id: 14007


[TOPIC: post.html]
#73

ricardorauber

[GLOBAL: userInfoPane.html]
ricardorauber
  • Contributor

  • 219 posts
  • Corona SDK

@iWalter

So you just have to use timers.
uid: 8556 topic_id: 2447 reply_id: 14010


[TOPIC: post.html]
#74

iWalter

[GLOBAL: userInfoPane.html]
iWalter
  • Enthusiast

  • 46 posts
  • Corona SDK

@ricardorauber

Do I need to create a local timer event function and call the changescene() function from it?
uid: 9936 topic_id: 2447 reply_id: 14019


[TOPIC: post.html]
#75

iWalter

[GLOBAL: userInfoPane.html]
iWalter
  • Enthusiast

  • 46 posts
  • Corona SDK

@ricardorauber

Thx for your help!

Just want to let you know that I got the image transitions to work with the timer functions.

All I need to do now is add some music and change the orientation to landscape.
uid: 9936 topic_id: 2447 reply_id: 14120



[topic_controls]
Page 3 of 4 1 2 3 4
 
[/topic_controls]