Having Trouble Switching Screens - ZIP Of Project Included

Hi,

Trying to switch screens (company screen to title screen).
I followed the tutorial “Color Slide”.
Everything is coded and setup.

I don’t know how to invoke the change in screens.
If someone could please download my project below and let me know how to do this:
(been trying to get this working for many hours)

http://fallenangelsoftware.com/stuff/files/RedLightRacer/RedLightRacer.zip

Thanks!

J.

Ok, so I took a look at the project. The title screen is in a separate collection and it is referenced in a collection proxy like this:

When the proxy has loaded you’ll get a “proxy_loaded” message back. When you get “proxy_loaded” you’re ready to show the loaded collection. You do that by posting an “enable” message.

I would recommend that you centralize all of the logic having to do with showing and hiding screens into a controller script. This script keeps track of the currently loaded screen/collection and does the “async_load” and “enable” calls as well as the “unload” call for any previous screen. Here’s an example of this:

This process of dealing with screens in a game has been simplified even further in the Monarch extension:

https://www.defold.com/community/projects/88415/

1 Like

Hi,

Thank you for the reply…

I added this code to Screen-1-FAS/ScreenFade.script

function update(self, dt)
	-- Add update code here
	-- Remove this function if not needed

	if ScreenFadeStatus == 0 and ScreenFadeAlpha > 0 then ScreenFadeAlpha = ScreenFadeAlpha - 0.1
	end

	if ScreenFadeStatus == 1 and ScreenFadeAlpha < 1 then
		ScreenFadeAlpha = ScreenFadeAlpha + 0.1

		if ScreenFadeAlpha == 1 then
			msg.post("Screen-1-FAS:/loader#proxy-Title", "async_load")
		end
	end
			
	go.set( "#ScreenFadeSprite", "tint", vmath.vector4( 1, 1, 1, ScreenFadeAlpha) )

end

But when I run the game I get the following error when the screen is changing:

ERROR:GAMEOBJECT: The collection 'Screen-1-FAS' could not be created since there is already a socket with the same name.

What did I do wrong?
Thanks!

J.

You have a problem with the naming of your collections. Read this. It explains your exact error: https://www.defold.com/manuals/collection-proxy/#_naming_collections

Here is a tip: If you run into trouble, chances are that others have encountered the same thing. You can use the search function on the forum to check:

In this case there are several hits that likely explains your problem.

There is also the search on the learn site. It works pretty well too:

Searching for information yourself is way, way faster since you get the answer immediately, and there is no need for others to do that work for you or to re-type information that already exist elsewhere.

2 Likes

Ok, so I cleared up the error, but am still having problems with switching screens…

Project ZIP has been updated:
http://fallenangelsoftware.com/stuff/files/RedLightRacer/RedLightRacer.zip

If someone can look at it and let me know the problem then we can continue with development.
Thanks!

J.

The problem is that you do not perform the required steps. @britzl explained them in his post above:

1 Like

You seem to be needing help at every step of development. Maybe you should spend more time reading the documentation completely before advancing with the project.

2 Likes

Honestly Jesse, looking at your project, not one of the things that is explained in the tutorial was coded. You did some preliminary setup, nothing more.

Please go through the beginner’s tutorials, step by step. Don’t just skim through the text, do the steps yourself.

I suggest you go through them in the following order:

  1. Side scroller
  2. Walking astronaut
  3. Color slide
4 Likes

Click below for a demo:
http://fallenangelsoftware.com/stuff/files/RedLightRacer/HTML5/js-web/RedLightRacer/index.html

1 Like