Game Development Community

guiBitMapCtrl Commands

by rennie moffat · in Torque Game Builder · 06/24/2011 (3:35 pm) · 26 replies

Hi there,
I am just getting into applying custom gui's and I have a few questions.


In the game I am building, I want to use the gui as a hud. In that hud I have numbers, which currently in my case are imageMaps (say numberCellImageMap). Currently, with out the gui, in the levelBuilder, sceneWindow, I change the number in the hud to the appropriate score, or frame. Is this approach, changing an image's ( a bitMap? ) frame on event possible for a guiBitMapCtrl object, or any other gui object or am I just waisting my time.

I suppose the other approach could be to use a guiTextCtrl object and change the info, content of the object.


If anyone has insight, or thoughts into how I can achieve this I would appreciate it.


Thanks.

About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.

Page «Previous 1 2
#1
06/24/2011 (4:05 pm)
You could attach an animated sprite to the scenewindow and change it's frame, to do the text display but you would need one animated sprite per number place. Usually the simpler approach won't make you want to slap yourself when you go back over the code later. So, really, I would just use a guiTxtCtrl to keep the resources and implementation to a minimum and then, if needed, change the font it uses to display.
#2
06/24/2011 (4:18 pm)
ok, and how would I change a guiTextCtrl object dynamically?

So say I want to change it from 7 to 1 on event? The docs I have gone over, give examples like set inviable, but it is tied to the name... hmm. will check out.
#3
06/24/2011 (5:41 pm)
You would set it's text via the property "text".

Here is an example from a project I'm working on:

guiHealthText.text=%this.life SPC "/" SPC %this.maxHealth;

#4
06/24/2011 (6:09 pm)
so what would that give me?


mostly, what is maxHealth?


better yet, what if I wanted the numbers to rotate thru, so say I am on 1 and need to get to 3, but I want a variable to represesnt any number 0-9. Can I do something like...


guiHealthText.text=%this.life SPC "Need this space to be a variable int!!!!!" SPC %this.maxHealth;


I know that makes no sense, but I need the text to be determined by a variable. See what I am doing currently is on ...

function this(%this)
{
%this.numberVar = %this.numberVar + 1;
%this.schedule(150, this);
guiHealthText.text=%this.numberVar;
}


???

sorry lazy friday night.
:)(



#5
06/24/2011 (6:47 pm)
%this.maxHealth -- %this refers to the current player object that is in memory for the player. It's property maxHealth is the variable inside of the player structure I keep the player's maximum health limit in, and %this.life is the player's current health at the time.

If you want to make an intermediary, yes you should add a delay like you did. If you want to animate the numbers, like on a rolling counter or a slot machine, you would need to use sprites to do that.

If you want a variable number, you can always use a variable that holds the number in place of text, or you can make the update into a function and pass in the number to use. So if you want to increment, you can either create a function that will take it's increment, or you can create a function that will take the final number and it can figure out how much to adjust the display by delaying for each number update to display. However you wish.

The major point is, if you want to dynamically update a guiTextControl's displayed value, you assign a new value to it's "text" property.

MyGuiTextControl.text = Whatever you want to be displayed here
#6
06/24/2011 (7:07 pm)
I think I could make an adjustment to my code so if x var true then varNum equals 3 etc and just plug that in but my question is, can I get the value of a text object? In that let's just say my guitextctrl is 3. Can I check that content (3) and since it is three, then use that info as I need? ie. Pass it in into a variable?
#7
06/24/2011 (7:10 pm)
Yes. You shouldn't have any issues with doing that. Just keep in mind that if you use characters in that string.. Such as text or words or symbols, your going to get funky values or an error, since they are not an integer value. Keep it to just numbers 0-9, and you should be fine.
#8
06/24/2011 (7:12 pm)
Niiice. Now I just have to figure out how to plug in my font. How are the resolutions of fonts in tgb? I have heard bad things, is that right?
#9
06/24/2011 (7:13 pm)
I wouldn't say bad things, but there is room for some improvement. You should check out the font helper resource. I can't confirm anything with "bad things" because it's not descriptive. I haven't had any really horrible issues, so I don't believe it's that bad. I do know that it takes some adjusting to a bit if you aren't used to working with graphics engines and such.
#10
06/24/2011 (7:21 pm)
OK will do.
Not to ask too much, but I am having issues with the custom gui's all together. This thread was to figure that aspect out, so thanks. But what I want to do overall is, have a hud background (so one image), then have each of the textObjects (say 7, each one unit 0-9), so I simply place these throughout and in the gui right?

It is just loading it, so far has not been fruitful, I followed the demo and nothing would show when I ran my game. I have a thread on it I posted earlier, you can see it here if you can get into the iTorque boards.
www.garagegames.com/community/forums/viewthread/126612/1#comment-810533

Another thing tho, can I have an animation in the gui?


But dont worry about it. It is Friday.
Thanks.
#11
06/24/2011 (7:36 pm)
One issue your snagging on in that other thread is the point that TGB (I don't know about iTGB) doesn't show profiles for any GUI Elements outside of what your game scripts have defined. You should check out this thread:
www.garagegames.com/community/forums/viewthread/125812

Although, I don't know about the functionality or lines in iTGB to edit. You can check and see if that doesn't help enable the profiles for view for you or not, but I make no warranties. As for the rest I'll check the docs here in a sec and see if I can figure out where your going wrong.

[edit]checked the documentation[/edit]
Ok, I checked the docs for anything animated in the GUI since I don't remember anything except for hover actions or button depresses being "animated". Simply put, no, not by default that I can see.

I didn't check the codebase. If you felt ambitious though, you could take the t2dAnimatedSprite and make a guiControl based off it in the codebase and recompile.

You can always add the t2dAnimated sprites to the sceneWindow dynamically upon level load or what not, that would be used for your "gui". Nothing says they have to be a GUI type and in all reality it doesn't matter if they are. Just make sure nothing is able to collide with them and they can't collide with anything else and they are always at the topmost layer of the scenewindow. I would probably create a non modal t2dSceneWindow and add the elements for the score into that scenewindow attach it to the current scenegraph and make sure events can flow through it. So that the animated sprites always stay in the same place no matter what is going on with the world behind it.
#12
06/25/2011 (2:07 am)
thanks man, I am going to go over this in the morning. It will be good to have the animation, but in my case, i just realized, since I only using two cells, in theory, i an just use setVisable, and flicker between.


Much Appreccioso.
:)))(
#13
06/25/2011 (4:50 pm)
@smally. Are you suggesting that you must create a script for the new guiControl which will hold those GUI objects? I thought that is what the guiBuilder will do.


#14
06/25/2011 (6:24 pm)
I was suggesting that you could create a t2dSceneWindow because the Gui Builder, as far as I know, doesn't have support for dropping in an animated sprite. You could just create a play scene gui, leave it blank and add the two animated sprites to it's scenewindow and attached to it's scenegraph as well. Which really is what I was meaning to suggest.

What I mean by a play scene gui is a gui that is used, only during gameplay, when the level is loaded and the scene is almost ready to go.
#15
06/25/2011 (6:37 pm)
Hmm. I am going to have to work this through. What I want to achieve is a HUD. ThT HUD will hold multiple objects. A background banner, 7 score items, and a couple of other buttons. All custom png's. Beyond animations, and what We were talking about my experiments last week did not prove fruitful in that when I expected to see my GUI, it did not show. Dimensions were not adjustable (at least in the builder) and a few things I was expecting to see via the documents examples, I did not.

I am going to try and tackle this more may e tomorrow, most Lilly Monday. I will be online tho, so if you have any thoughts I would love to hear them.

Cheers
Ren
#16
06/25/2011 (6:56 pm)
Ren, You can always set the extents of your gui and it's children objects. The only issue I can see with what you want to do, is that the gui builder just doesn't have the drop in placement for a t2dAnimatedSprite. So, for that, you could just design everything else for your hud in the builder, and then either on or after level load, you can add those two animated sprites dynamically to the scenewindow of your hud and it's scenegraph. You should be good to go with that. Example, the first iteration of the lighting I was building for my project used this method to create a lightmap that would be applied over the scene. Since I didn't want to have to render lighting for every object in the world, I only rendered what is visible in the scene, and applied it to a bitmap overlay in the game's hud using this technique. The only difference is, you have to track this kind of thing by yourself as the GUI Builder doesn't have support to drop in native objects like a t2dAnimatedSprite. :( I know it's a slight pain, but it's a work around, at least.

If you have issues on monday, send me an e-mail and we can exchange IM info so we can see what we can do about getting you fixed up and running w/ the gui itself. I can't see why it's not showing up, because I can't see your project or code in it :/ but would be glad to help.
#17
06/25/2011 (7:00 pm)
thanks smally.


To tell you the truth, the animation is ixneh, as in I am not going to use it. I can do, the animation I wanted, simply by setting an object to be visible, schedule, inviable, like a little flicker as thats all the animation was.

Beyond that, if you think it should be easy, that is reassuring. If we can IM etc, that would be great.

You can email me your info. I am at renniemoffat@gmail.com



ThANKs!
#18
06/25/2011 (7:19 pm)
Then that works lol.. NP!
#19
06/26/2011 (9:36 am)
So I have done some tests, via...

Canvas.pushDialog(hudScreenGui);

I am calling my hud into place. Two weird things have occurred.

Following the example, I did the test and it worked fine (the example uses mainScreenGui), but, I can not see it in my project, under a custom gui, hudWindow2D.

My code is as this.. game starts on a "startPage" (go figure. I press start and it takes me to the level, it is in that level that i call the gui into place, just like above.. Canvas.pushDialog(hudWindow2D).

I am running an echo on the gui objects place and getting accurate feedback. I also moved the loaded level out of the way temporarily so I could see the black background thinking the gui may be behind it. But no dice, nothing, visually was there.

I am not sure what I am doing wrong. Any advice?


ps. my gui object, in tests took up the whole gui space and placed it at 0 0. So, it should not be hidden. And I am calling the file in the main.cs.



#20
06/26/2011 (11:12 am)
Can you post some code, so I can see what's going on?
Page «Previous 1 2