Game Development Community

Need help with porting..... again....

by Jereis Zaatri · in iTorque 2D · 06/21/2010 (5:17 pm) · 17 replies

Hello,

I'm figuring out why my game crashes when I load the first level. Can someone explain what sceneWindow2D is? It seems to pop out of nowhere. It obviously has something to deal with setting up a GUI. My problem is there is a call "sceneWindow2D.loadLevel(%level);", but nothing happens.

Anyone have a clue what may be going on?

#1
06/21/2010 (8:26 pm)
The input parameter %level should be a string that contains the path and filename of the level file that gets loaded. That variable should contain something like: "game/data/levels/xxxx.t2d" where the xxxx is the name of the level. So take a look at what is being passed into "%level" to make sure it corresponds to a valid file.

Also, after you run your code take a look inside the "console.log" file to see if there are any error messages.
#2
06/21/2010 (8:47 pm)
Jereis

Every level requires a GUI file, even if you are not using HUD part. You can also use one GUI for all your levels.

The gui you define what is displayed on the screen. The scenewindow is the area where the game is played (playfield). The graphical user interface (GUI) things like score, etc. HUD = Heads up display.

The command

sceneWindow2D.loadLevel(%level);

Means: load the level (stored in the %level variable) into the sceneWindow2D.

new t2dSceneWindow(sceneWindow2D) {
...
   }

The %level variable is read from common/commonConfig.xml

example:
<DefaultScene>~/data/levels/Level1.t2d</DefaultScene>
#3
06/23/2010 (2:35 am)
Thanks for the info... turns out my problem was from mixing up two project while port and forgetting a few data blocks -_-. But thanks for the help.

Bellow is piece of code that puzzled me with the mouse events not working until I figured it out (see my update)

new GuiChunkedBitmapCtrl(mainScreenGui) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
Position = "0 0";
Extent = "1024 768";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
bitmap = "~/data/images/backgrounds/blueGUI";
useVariable = "0";
tile = "0";
noCursor = false;

new t2dSceneWindow(sceneWindow2D) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
Position = "0 0";
Extent = "1024 768";
MinExtent = "8 8";
canSave = "1";
Visible = "1";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "1";
};

new t2dSceneWindow(EffectWindow) {
canSaveDynamicFields = "0";
Profile = "GuiContentProfile";
HorizSizing = "width";
VertSizing = "height";
Position = "0 0";
Extent = "1024 768";
MinExtent = "8 8";
canSave = "1";
Visible = "0";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "0";
};

new GuiBitmapCtrl(PauseTextGui) {
canSaveDynamicFields = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "center";
VertSizing = "center";
position = "0 0";
Extent = "83 41";
MinExtent = "8 2";
canSave = "1";
Visible = "0";
hovertime = "1000";
bitmap = "~/data/images/guiImg/paused";
useVariable = "0";
tile = "0";
};
};


=Update=
If you came across my earlier post about t2dSceneWindow, just ignore it, I figured out why there was 2 of them.

On that note is having multiple t2dSceneWindow in a GUI a performance hog on the iphone? Also if you can have 2 t2dSceneWindow in a GUI can you have two levels loaded at one time? Lastly from reading the code, the only purpose it seems to serve is to turn the screen red. What's the advantage of doing it by placing another t2dSceneWindow than doing it in the same t2dSceneWindow?

Last Question I have is if you have two gui elements in the same bracket depth is the second one always guaranteed to be in front?

Thanks
#4
06/23/2010 (2:45 am)
I'm not a Torque GUI person but those windows look the same to me - I guess the effects might be an overlay for "effects" of some sort. WRT to the mouse event - I think the effect window covers the other and therefore consumes the mouse event - meaning the other window doesn't see it. Normally there is some setting that will let the other (hidden) window also get the mouse event.

If you don't need the effects window then I would comment it out for now and see if it makes a difference to your game.
#5
06/23/2010 (3:11 am)
Once again I solve the problem right after post my question..... but I still have those other questions...
VVVVVVV--------------------------------------VVVVVV
If you came across my earlier post about t2dSceneWindow, just ignore it, I figured out why there was 2 of them.

On that note, is having multiple t2dSceneWindow in a GUI a performance hog on the iphone? Also if you can have 2 t2dSceneWindow in a GUI can you have two levels loaded at one time? Lastly from reading the code, the only purpose it seems to serve is to turn the screen red. What's the advantage of doing it by placing another t2dSceneWindow than doing it in the same t2dSceneWindow?

Last Question I have is if you have two gui elements in the same bracket depth is the second one always guaranteed to be in front?

I'm going to sleep now, so I'm sure you'll have the opportunity to answer it before I wake up. ^_^


Sorry about that...
#6
06/23/2010 (9:50 am)
Hello again ;)

Not wanting to give out my super duper secrets, but my game has 2 t2dscenewindows. 1 is play field and 1 is for gauges.

If you have 2 full games in 2 windows, that will eat a cpu cycles. Why would you need 2 levels loaded at the same time. If you look at games on xbox 360, with split screen, they do not play as well as the single screen.

If you want split screen, i remember seeing a post in the forums that shows how to do this.

The biggest hit on performance comes from graphics that are not optimized for iphone. Most people have images that are too big and are resized in the itgb. that image being resized, in itgb, does not make the image any smaller in KB. You need to resize them in a paint program like photoshop or paint.net (free)

The other hit comes from sound/music files that are too large. Some of the best flash games, the sound files are 32kb. You do not need sound/music files with 128kb sample rate.

Use images for effects instead of particle effects.

Use the tools that come with itgb for combing pictures. I do not use the pvr files.

The iphone is not a game machine and has limits. I am not sure what the limits are, but if you follow the above rules, you will have a good performing game.

Lastly, the answer to life, the universe and everything is 42.
#7
06/23/2010 (10:32 am)
Thanks for the tip!

I know you said it your secret, but is the one used for the gauges done that way because GUI lack capabilities to do animations? Also do you do it by creating another scene and loading that scene onto it?

Also is there a way to make it click through? Now that you bring up the gauge idea, I'm considering make use of such things.

Also does iTGB have masks such that if I only want a certain portion of an image to show, it'll hide the rest?
#8
06/23/2010 (12:22 pm)
@Jereis

I was teasing about the super duper secret. If you look at my game, I do have animation in the GUI, the plane moves around and it is a GUI item. It is possible to do simple animation on the GUI layer.

The double window was used because the GUI does not allow rotating of objects (needles). There is a fix in a post, but it is old and does not apply to itgb and was too hard to put in place.

I created 2 windows and they sit over top of each other. they are 480 by 320 and XY 0,0

In the gauge window, I load my gauge level, there is only 4 items in the level.

In the playfield level, i load my game.

In the GUI builder, you can move windows to the top, so my GUI is top, gauge window, followed by playfield.

It can click through if you have nothing blocking it. meaning it is transparent. The top item will click block anything that is underneath.

I am not sure if my idea is the best, but it's what I came up with.
#9
06/23/2010 (12:56 pm)
Thanks for the info, I have one more questions. What is the cleanest way to do animation in the gui layer?
#10
06/24/2010 (12:31 am)
Help me.... again!

What is responsible for enabling the onUpdate callback?

Thanks again
#11
06/24/2010 (8:45 am)
You need to set the flag in your level file; UseUpdateCallback = "1";
#12
06/24/2010 (10:48 am)
Thanks again, but now I can figure out why the player doesn't move even though I've given the player a velocity? There's nothing for the player to collide with so I'm puzzled as to why the player can't move. what other factors can influence an objects movement?
#13
06/24/2010 (12:07 pm)
You need to set the flag UsesPhysics = "1" on any object that you want to move.
#14
06/24/2010 (1:16 pm)
hmmmm..... wonder how it worked before I proted the game.... odd

Thanks again.
#15
06/24/2010 (1:17 pm)
TGB (Mac/PC) has physics enabled by default, on the iDevices it is disabled by default.
#16
06/24/2010 (2:19 pm)
What I have done, is use torque script to handle this. Sometimes when you are editing a level and save, I've had it
revert the physics = 0

In the game.cs script after you load the level, you would do something like...

load level .....

player.setUsePhysics(true);
enemy.setUsePhysics(true);
#17
06/26/2010 (6:02 pm)
@Jereis

I have posted a resource on how do to simple GUI animation.

www.torquepowered.com/community/resources/view/19905