Game Development Community

Stationary image?

by Joe O · in iTorque 2D · 02/09/2012 (8:58 am) · 6 replies

I have a couple ideas on this but so far I haven't made it work yet. Hopefully someone here will have done this.

I have a blank image that is mounted to the camera. When I drag it, it drags the camera and the contents in the scene shift on the canvas as the camera moves. What I would like is to have one set of objects never move. They're my background objects - off in the distance. How can I do this?

My thoughts are:

Find a way to update the image as the camera moves.
- This fails because the camera continues to pan (like inertia) after the touch and slows down to a stop. The background image follows suit and it looks awkward.

Find a way to mount the image to the scene.
- This one failed because the draggable camera becomes untouchable. This might be the right way to do it and I don't pass the proper parameters to the mount method yet.

Find a way to load two scenes (like I've seen other people use for HUDs).
- I haven't gone this route yet... It seems feasible but it would take a bit more effort than the other two.

Any pointers appreciated! Thank you!

#1
02/09/2012 (9:01 am)
And just like that.... I read the doc one more time and realized my folly.

Turns out I can just take my backgroundImage and mount( %this, 0,0, true, true ) in my DraggableCamera and everyone is just peachy king. (Note that %this refers to the DraggableCamera).
#2
02/10/2012 (12:33 pm)
There is that option, but there is an alternative. You can store all your stationary objects in a separate window/scenegraph and load that on top of your main game level.
#3
04/22/2012 (10:21 am)
I think I'm disillusioned with my current approach...

The alternative sounds interesting. Do you have any specifics as to how it might work? I'm not sure how I would make a new sceneWindow2D or if it's even possible. Do you have any examples you might be able to share?
#4
04/22/2012 (1:18 pm)
Just make it!

Here's a mainScreen.gui from a desktop project:
%guiContent = new GuiControl(mainScreenGui) {
	canSaveDynamicFields = "0";
	isContainer = "1";
	Profile = "GuiDefaultProfile";
	HorizSizing = "width";
	VertSizing = "height";
	Position = "0 0";
	Extent = $Game::Resolution;
	MinExtent = "8 8";
	canSave = "1";
	Visible = "1";
	hovertime = "1000";

	new t2dSceneWindow(gameWindow)
	{
		canSaveDynamicFields = "0";
		isContainer = "0";
		Profile = "GuiText24Profile";
		HorizSizing = "width";
		VertSizing = "height";
		Position = $Game::ExtentPos;
		Extent = $Game::Extent;
		MinExtent = "8 8";
		canSave = "1";
		Visible = "1";
		tooltipprofile = "GuiDefaultProfile";
		hovertime = "1000";
		lockMouse = "0";
		useWindowMouseEvents = "0";
		useObjectMouseEvents = "0";
	};
	new t2dSceneWindow(osdWindow)
	{
		canSaveDynamicFields = "0";
		Profile = "GuiContentProfile";
		HorizSizing = "width";
		VertSizing = "height";
		Position = $Game::ExtentPos;
		Extent = $Game::Extent;
		MinExtent = "8 8";
		canSave = "0";
		Visible = "0";
		lockMouse = "0";
		useWindowMouseEvents = "0";
		useObjectMouseEvents = "0";
	};
};
This is the only GUI file in the project. All GUIs are actually scenes with sprites for buttons and displays, because it doesn't ned any advanced controls beyond buttons.

All you have to do is to design the OSD of your game as a scene, and load that scene into the correct window:
// Fill in variables with paths of scenes
	gameWindow.loadLevel(%level);
	osdWindow.loadLevel(%hud);

I have more layers of windows than this in some projects, too. For instance, a layer behind for a background image so that I can keep the actual levels transparent and change the background through simply loading an appropriate level. Or a layer in front of everything to put a transition animation scene before loading a new level.

The order of windows is back to front. Last one defined is the frontmost, in other words.
#5
04/23/2012 (8:19 am)
Oh!

I knew I should have been grepping through the gui files too. Thanks for the tip! This works just like I thought it should but connects the dots for where that screen is defined :)

Thanks!
#6
04/23/2012 (8:28 pm)
Thanks Ronny - that really did the trick! Works exactly like I wanted to.