Game Development Community

[Solved] add hud scene

by Ghonium · in iTorque 2D · 10/11/2011 (10:35 am) · 12 replies

I have buttons on screen
when I press one of these button it make the player to move up
the problem
I mounted the camera to the player
and when I press upButton the player move but the button stay down until it disappear from screen

are there any way to make the buttons and player stay on screen?

any idea please ?

#1
10/11/2011 (3:17 pm)
I believe so, (tho I am currently having trouble with cameraMount all together. Are you using 1.5? can I see your mount code?)... as far as mounting multiple objects to your camera mount.. ever think of something like, have a large object call it objectX (t2dSceneObject, 480x320 || 320x480) mount your camera to that AND mount each object to that objectX. When you pull a object into the editor, you can select "Link Points" this window lets you adjust and set, countless I believe mount points, then simply mount the objects to that objectX, plus the camera. That should work I believe.


#2
10/11/2011 (11:35 pm)
Yes I use 1.5
I used camera mount behavior which come in some tutorials
but I think if I want to mount the button and the player
I should make the button also move when the player move
which will be hard for my skill

I may use Gui if possible? but not sure about things in Gui since im beginner programmer
about the Gui:
1- is it possible to change Gui button to onTouchDown and onTouchUp ?
2- are Gui buttons can accept multiTouch ? because there will be 3 buttons 1up 1left 1right
#3
10/12/2011 (7:14 am)
Yes.
I recently began using a second gui. This can be done quite easily. However, keep in mind, as far as iTGB touch and mouse events, ( certainly mouse, probably touch too) can not pass thru the top scenegrapgh to any below it, so... simply create globals (what I did).

So, build a second gui to sit on top of the game scene. The top gui, will hold your controls. So, onMouseDown, (touchDown>...? still not fully sure of the new touch commands and their full plethra of ability) set $player to move etc.


#4
10/12/2011 (8:40 am)
I think there are some way to edit the script to make the Gui able to onMouseDown and Up

but is it able to use GUI buttons in multiTouch ?

Button A up
Button B left
Button C right

can we press the three Gui same time to change direction or rotate while go up ?
#5
10/12/2011 (9:06 am)
My point is that despite many attempts and time I have spent looking into it, I did not find a way to pass touch events thru a gui to another behind it. That being said I have not tried with the new touch events. Instead all my work was done with the mouseEvents.

And yes, the beauty with onTouch is that it can send multiple events.. as in, if touch triggered on one object, touch can be triggered on another too. With mouse events only one mouse event could ever be passed.
#6
10/12/2011 (9:27 am)
but there must be way to do it
I have one cocos2d proj tutorial, have many buttons and they stay on screen corner all the time
one for handler as joystick and one button for sword and one for shield

there maybe a way to do buttons here and stay on screen when character move
ill wait sometime maybe someone know can explain it?

#7
10/12/2011 (9:43 am)
yes you can.
i am telling you how. either mount the btns to an object which has the camera mounted to it or create a second gui where the btns will always stay still in position.
#8
10/12/2011 (10:01 am)
I think that this should help you

http://www.garagegames.com/community/forums/viewthread/127281
#9
10/12/2011 (11:20 am)
thank you Andrea Ill read it until I digest the info

but I think yes this should solve the problem

if I couldnt understand it ill post here or there
thanks again :)
#10
10/13/2011 (1:10 pm)
rennie can you help me how to do the hud

Idid the same what you did on this link
http://www.garagegames.com/community/forums/viewthread/125186

i made new project added 2 levels
i added 1 image in level1.t2d
and another different image on hud.t2d
also i changed the gui mainScreen as in ur link
also I added
// Load the .t2d file for this game
   sceneWindow2D.loadLevel(%level);
    hudWindow.loadLevel("data/levels/hudScene.t2d"); //added to load second scene
to the game.cs

but when i run i get only 1 image not both images

i use itorque 1.5
help me please im tired of this hud
#11
10/13/2011 (5:42 pm)
Ok. well did you create a second gui? If not just copy your mainScreen.gui and save it as hudScreen.gui. Also, adjust the names so sceneWindow2D, becomes hudWindow2D, mainScreenGUI becomes hudScreenGUI.


then, I use this in a btn.

function loadLevelBtnBehavior::loadNewGame(%this)
{	
	echo("loadLevel::loadLevel");
	sceneWindow2D.endLevel();   ///ends level in sceneWindow2D
	sceneWindow2D.loadLevel("data/levels/levelTest.t2d");    //loads, in my case playable level
	hudWindow2D.loadLevel("data/levels/hudScreen.t2d");    /// then load hud level via the hud gui
	Canvas.pushDialog(hudWindow2D);	   //// to be sure push the hud window to the top of the scenegraph layers
}



and thats it.




#12
10/14/2011 (1:37 am)
thank you Rennie
thank you Andrea
now it worked
my mistake was because i didnt do second gui file

now I will need to add onTouchDown from Andrea post

http://www.garagegames.com/community/forums/viewthread/127281