Game Development Community

sceneWindow2D definition

by rennie moffat · in Torque Game Builder · 08/22/2009 (11:51 am) · 29 replies

What it is the definition of a sceneWindow2D. Looking in ref material and can't find a clear definition. I think it is the seeable window (what is currently "on screen"), but not 100%. 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
08/22/2009 (8:12 pm)
When I first started with T2D, this threw me for a loop, too.

The quick answer is that this is just an instance of a t2dSceneWindow. You'll find this in the game/gui/mainScreen.gui file.

99% of the time that there is a name that appears out of nowhere, it is often part of the T2D foundation (a phrase which means the base stuff that almost everybody uses and is created by default in each new project). If you have Torsion, it has a great "Find In Files" (Ctrl-Shift-F) function which helps you find these pieces.

If you don't have Torsion, find a tool which has a great directory search (Window's built-in search is horrible and never works for me). This can even be Microsoft's free Visual Studio Express Edition.

Searching the scripts is more powerful than you can imagine. As you search for these globally named objects (like sceneWindow2D), you'll often find portions of the scripts that you've never seen before and helpful functions that you didn't know existed. Kind of like looking through the dictionary for a word and finding more interesting entries.
#2
08/24/2009 (1:00 am)
Hey, thanks for replying I will be going over the posts tomorrow and this week since this is my direction, sorry for any delay.



#3
08/24/2009 (12:33 pm)
ok,
just looked, I am on a Mac, and cannot seem to open the mainScreen.gui. Any suggestions as to how I might be able to see this data?



quote:
99% of the time that there is a name that appears out of nowhere, it is often part of the T2D foundation (a phrase which means the base stuff that almost everybody uses and is created by default in each new project). If you have Torsion, it has a great "Find In Files" (Ctrl-Shift-F) function which helps you find these pieces.


me:
ok, so what would I be looking for here?
I checked out Visual Express. Ended up downlaoding Eclispe. www.eclipse.org.
not sure if she is a keeper yet.

we'll see in the future.




RE: Finding key words, and discovering new paths, sounds so exciting to me. I Like that kind of stuff. It's like when you fall and then you get back up, or some old way of finding out something you never knew existed. Anyways, I have seen some of that stuff. I have no problem with realizing new things. But essentially wisdom is key, so I am going to keep studying. ause right now its not good enough. I need to know more. But I am sure I will. just keep pluggin in. and away.



([:.]+--|





#4
08/24/2009 (1:01 pm)
Here's some info I found which describes it better than I could explain:

The Scene Window is the actual GUI object that the game is displayed on, the default Scene Window used is called �SceneWindow2D.� Once we have our Scene Window name we can add some simple script function calls like these:

function sceneWindow2D::onMouseMove( %this, %modifier, %worldPos, %mouseClicks )
{
}

function sceneWindow2D::onMouseDragged( %this, %modifier, %worldPos, %mouseClicks )
{
}

function sceneWindow2D::onMouseDown( %this, %modifier, %worldPos, %mouseClicks )
{
}

function sceneWindow2D::onMouseUp( %this, %modifier, %worldPos, %mouseClicks )
{
}

function sceneWindow2D::onMouseEnter( %this, %modifier, %worldPos, %mouseClicks )
{
}

function sceneWindow2D::onMouseLeave( %this, %modifier, %worldPos, %mouseClicks )
{
}

function sceneWindow2D::onRightMouseDragged( %this, %modifier, %worldPos, %mouseClicks )
{
}

function sceneWindow2D::onRightMouseDown( %this, %modifier, %worldPos, %mouseClicks )
{
}

function sceneWindow2D::onRightMouseUp( %this, %modifier, %worldPos, %mouseClicks )
{
}

I hope this helps some.
#5
08/24/2009 (1:11 pm)
sure so it is a class.
But why would I declare scene2DWindow over say. that object?
#6
08/24/2009 (2:44 pm)
Ahhhh... I didn't know you were on a Mac. You still should be able to look at mainScreen.gui with any text editor. You might look around on the forums for an XCode plugin to view scripts. I've also had very good luck searching for specific code using the "[Wiggley Key]-Space" (I don't know what it's called) search functionality.

You could use either "sceneWindow2D::onMouseUp" or "t2dSceneWindow::onMouseUp". In the first case, the "%this" variable will always be the same object as sceneWindow2D. In the second case, the "%this" variable would be on the scene window you were over (imagine having 2 scene windows side-by-side).

This works because sceneWindow2D _is_ a t2dSceneWindow. A t2dSceneWindow was created with a global name of sceneWindow2D (not to be mistaken with global variable, but very similar). This is what you'd see in the mainScreen.gui file.

Later!
#7
08/24/2009 (4:40 pm)
I did some research,
a sceneWindow2d is, through a quick search asscociated with:
mouse events, camera postioning, and scengraphs,

where as t2dSceneWindow is associated with object follow check, mouse events (as well), canvas and window points.


further...
from your quotes:


"sceneWindow2D::onMouseUp"
%this" variable will always be the same object as sceneWindow2D

"t2dSceneWindow::onMouseUp"
"%this" variable would be on the scene window you were over (imagine having 2 scene windows side-by-side).
////so sceneWindow is an object, like an image, while t2dSceneWindow is an object in that main, global window? ie a level?




if this is true,
and sceneWindow2D is an object, why not? can I? simply give it a name, like "thatThing"?

this way I could use it as a class and in a string.









#8
08/24/2009 (4:58 pm)
Not quite...

A t2dSceneWindow is a class that has functions to do mouse events, move the camera, display a scene graph, load a scene, etc. The vast majority of this functionality is defined in a C++ class. A little bit of it is extended in the C-Scripts.

In mainScreen.gui, an instance of t2dSceneWindow is created. Literally, a "new t2dSceneWindow" is called. Looking at the file, you'll see the line:
new t2dSceneWindow(sceneWindow2D) {

The "sceneWindow2D" on that line is the name of the new t2dSceneWindow. It has all of the behavior that t2dSceneWindow defines. It allows you to do:
sceneWindow2D.setCurrentCameraPosition( "0 0" );

If you look in mainScreen.gui, you'll notice that the sceneWindow2D is enclosed by another object, mainScreenGui. If you do a global search for mainScreenGui, you'll find it is used in the first line of the function "startGame". Specifically, it'll set the Canvas (which you can consider to be the entire application's window) to mainScreenGui.

Now the application is showing the mainScreenGui which contains a sceneWindow2D. Everything in the sceneWindow2D is now being rendered.

Later!
#9
08/24/2009 (5:17 pm)
ok, so i opened tbe mainScreenGui in text edit (mac).
and saw this...
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";
};


so the sceneWindow2D is an instance of the t2dsceneWindow? So it carries the properties passed onto it in the t2dSceneWindow.



Right? Close?

;]ppp




#10
08/24/2009 (5:19 pm)

if so,
does that mean that the certain things defined in the/by the t2dSceneWindow are directly applied to, can be represented by the sceneWindow2D?
#11
08/24/2009 (6:26 pm)
Exactly! Everything that the t2dSceneWindow defines (funtion-wise) is in sceneWindow2D because sceneWindow2D is a t2dSceneWindow.

Think of it like a person. Classes of type person can walk, but you need a specific instance of a person (say, William), in order to actually call the walk function. Person is an abstract concept and cannot walk, William is a specific instance of that concept that can.

new Person(William) {};

Person defines the behaviors, and the instance that is created (Rennie) does the actual behaviors.

You could rename sceneWindow2D to RenniesSceneWindow or MyGameSceneWindow or FunkyTown. I don't recommend it, simply because a lot of the resources, tutorials, and forums posts assume that you've left the name alone.

Edit Addition:
I guess to implement my analogy, I'd say that a t2dSceneWindow is a concept that contains a camera looking at a scene. sceneWindow2D is an instance of that concept that actually has the camera.
#12
08/24/2009 (8:29 pm)
Awesome!

gonna look at this more in a bit.
#13
08/25/2009 (12:07 pm)
so perhaps this analogy might work...


A movie set is the t2dSceneWindow

The camera filming the actual movie is the sceneWindow


:maybe?
How would this relate if this analogy is accurate?





#14
08/25/2009 (6:32 pm)
Not quite...

A t2dSceneWindow is the concept of a camera. Then you ask for a new camera and call it sceneWindow2D. You could call is Camera1 if you wanted. In addition to having a camera, t2dSceneWindow also defines the concept of a camera's output monitor (the size of monitor and it's location in the application's window).

In TGB, there is another concept of a "movie set" which is called t2dSceneGraph. Conceptually, it would have props and actors. Until you actually make a new t2dSceneGraph and give it a name (like $lastLoadedScene), you have no movie set.

When you create actors (t2dStaticSprites, say), you tell them which scene graph ("movie set") they are in.

You also tell the scene window which scene graph to look at. Now you have a camera (sceneWindow2D) looking at a "movie set" ($lastLoadedScene).

This is really powerful. You could create an enormous scene graph that covers an enormous area. You have one camera that is zoomed in on the character and the output is the whole application's window (like a classic Zelda game). THEN! You could have another camera looking at the same scene graph, but zoomed WAY out. It's output area would be a little square in the bottom left-hand corner. This would act as a mini-map of the entire area.

Hope that clarifies some things. Later!
William
#15
08/25/2009 (11:44 pm)
so, what wold a sceneWindow2D be used for? A level?



#16
08/26/2009 (3:01 am)
For a lot of people, the sceneWindow2D (the camera and monitor) is used for the entire time that the application is running.

A scene graph (your movie set) is then used to create the levels. You typically create the various scene graphs using TGB or programatically through code.

The sceneWindow2D has a behavior called "loadLevel" which could be considered as a way to switch scenes while using the same camera.
#17
08/26/2009 (8:16 am)
So you say, use the same camera when switching scenes/levels ( levels is true?). If so, when switching scenes/levels but using the same camera.. what is the result, benefit, example of?



I say this meaning, my only example in my head, but it is not for a video game. I am thinking when I have my computer on, and I have say 3 windows open, ie, internet. I can choose any scene, but it is the overall, same camera, monitor, viewing area.



:?

#18
08/26/2009 (5:11 pm)
Using the classic Zelda example, you have a big world, but you have some custom camera code (for example, to keep your combat target and yourself on the screen during battles). Now, when you load the next world, you'll still have this custom camera code available because you used the same camera.
#19
08/26/2009 (6:36 pm)
ok so when you say camera,
you mean properties assigned to it/ or the view itself.


#20
08/26/2009 (6:43 pm)
so to elaborate...
a camera may be tagged to a player,
and that camera movement will have certain properties assigned to it. Like follow player X.



But the t2dSceneWindow would hold say the Map, Level X, Y, Z?


Or is the t2dSceneWindow, all the info that may be offscreen?
Page «Previous 1 2