Please post someone full creation process gui colection proxys button?

Example of creation proxy meniu buttons in levels like score and in main meniu.Please give example with explanations.

Code samples: http://www.defold.com/tutorials/

But can you give me some of yours exaples?

Could you please tell us what it is that you think the tutorials are lacking and maybe we can look into that?

i think in tutorials need to be more explications and special for main meniu because there is script that show us more animation thaт process to switch levels.

This thread explains it, and was the basis for my setup.

2 Likes

I saw this tutorial but what i need to do if i have a gui button because gui script i cant attach to GO ?

Use message passing.

You associate normal scripts to GOs not GUI scripts.

1 Like

What did you mean? I have a gui script that handle proxys switch and button. I cant make a clickable gui proxy button.

The following is just ripped out of my code, and therefore might lack some context. But it should be readable.

In gui-script of menu:
My click handler in menu guy script. game_loader is the name of my loader collection. loader is a game-object with the collection proxy and a script. (Don’t mind the FB references)

       if action_id == hash('touch') and action.pressed then
		if gui.pick_node(gui.get_node("menu_play_btn"), action.x, action.y) then
    		msg.post("game_loader:/loader#script", "start_game")
    	elseif gui.pick_node(gui.get_node("fb_pic"), action.x, action.y) then
    		msg.post("game_loader:/loader#script", "save_picture")
		elseif	gui.pick_node(gui.get_node("menu_fb_login_btn"), action.x, action.y) then
			if facebook.access_token() ~= nil then
				msg.post("game_loader:/loader#script", "fb_logout")
			else
				msg.post("game_loader:/loader#script", "fb_login")
			end
		end
	end

From the script in loader game object:
What happens when I push the “menu_play_btn”

if message_id == hash("start_game") then
	msg.post("gui#gui", "disable")
	load_main(self) ...

Load main function:

local function load_main(self)
	msg.post("#main", "load")
end

main is the name of the collection proxy inside my loader game object, inside game_loader collection.

1 Like

I’ve created an example of a menu and a game collection being loaded and unloaded via a controller script. You can see it in action here:

Menu and Game 0.0 (tap to remove the five alien dudes in the “game” to return to the menu)

And the code here:

4 Likes