Trouble with sceneWindow2D.mount( $player )
by Don Hogan · in Torque Game Builder · 07/02/2005 (8:36 pm) · 8 replies
I've read the threads on this, and I still can't get it to work. ( http://www.garagegames.com/mg/forums/result.thread.php?qt=26865 and http://www.garagegames.com/mg/forums/result.thread.php?qt=28790 ) The player ship goes off screen just fine, but the camera never budges. I *think* I have it setup so that the camera view is 1/4 the size of the world area and centered on 0,0 - if I change the camera view to be the full area the player is 1/2 size and can travel to and slide along the edge of the world.
I feel like I'm missing something obvious, so I thought I'd post it and ask. Here's what I have in my client.cs file.
I feel like I'm missing something obvious, so I thought I'd post it and ask. Here's what I have in my client.cs file.
// --------------------------------------------------------------------
// Setup T2D Scene.
// --------------------------------------------------------------------
function setupT2DScene()
{
// Create fxSceneGraph2D.
new fxSceneGraph2D(t2dSceneGraph);
// Associate Scenegraph with Window.
sceneWindow2D.setSceneGraph( t2dSceneGraph );
// Set the size of the world map
sceneWindow2D.setWorldLimit( clamp, "-80 -60 80 60", false );
// Position camera, attach it to player, set map limit
sceneWindow2D.setCurrentCameraPosition( "0 0 80 60" );
sceneWindow2D.mount( $player );
sceneWindow2D.setViewLimitOn("-80 -60 80 60");
}
#2
Is that the right answer, or are you referring to something else?
Thank you for being on top of this so fast, Matthew!
07/02/2005 (8:53 pm)
I'm building on the T2D folder base, so 'CreatePlayer();' is called in 'function initialiseClient()' at the beginning of the file.Is that the right answer, or are you referring to something else?
Thank you for being on top of this so fast, Matthew!
#3
07/02/2005 (9:09 pm)
I don't think that order will work since you need to assign a scenegraph to the $player when you create it so between creating the scenegraph and setting the window to the player you need to create the player
#4
07/03/2005 (12:03 am)
Btw, i just love the misspelling of initialize... thankfully it's just a script function and not hard coded into the game engine :)
#5
07/03/2005 (9:25 am)
Not a misspelling :) Its the British proper English spelling, Melv is from the UK.
#6
Would I have to be set up in a project that loads separate .cs files? I.e. like Spacescroller loads client.cs, player.cs, enemy.cs etc.? Ultimately that's what I hope to do so my programmer and I can work in tandem, but the one time I tried to set up that system I didn't get it, either. ( Boy, that's an annoying trend, isn't it? Well, at least I am managing to get my head around the tile editor and it's world space coordinate system. One step at a time. :D )
- Don
07/03/2005 (9:30 am)
I looked at this last night, and was just too tired to think, so I came back to it this morning. Unfortunately, I still don't get it. :( Would I have to be set up in a project that loads separate .cs files? I.e. like Spacescroller loads client.cs, player.cs, enemy.cs etc.? Ultimately that's what I hope to do so my programmer and I can work in tandem, but the one time I tried to set up that system I didn't get it, either. ( Boy, that's an annoying trend, isn't it? Well, at least I am managing to get my head around the tile editor and it's world space coordinate system. One step at a time. :D )
- Don
#7
// Create fxSceneGraph2D. new fxSceneGraph2D(t2dSceneGraph);
In that line you create the scenegraph... the world in which you will put 2D objects in... like when you create a static sprite you do something like this
you have to tell it a scenegraph to put the player into on creation. Now this means a scenegraph must already exist...
The problem I see with your code is that you just created the scenegraph, then a few lines down you attach "$player" to the camera... now since you just created the scenegraph the player creation code has to be after creating the scenegraph or there is no scenegraph in existence to attach the player to.
07/03/2005 (9:34 am)
Ok, I'll try to explain it a little better// Create fxSceneGraph2D. new fxSceneGraph2D(t2dSceneGraph);
In that line you create the scenegraph... the world in which you will put 2D objects in... like when you create a static sprite you do something like this
$player = new fxStaticSprite2D(player) { scenegraph = t2dSceneGraph; };you have to tell it a scenegraph to put the player into on creation. Now this means a scenegraph must already exist...
The problem I see with your code is that you just created the scenegraph, then a few lines down you attach "$player" to the camera... now since you just created the scenegraph the player creation code has to be after creating the scenegraph or there is no scenegraph in existence to attach the player to.
#8
07/05/2005 (5:18 am)
Thanks again, Matthew, that was a good description and I finally got my artist brain wrapped around it. =) I also actually managed to get it working and now just have to deal with the tile map not lining up the way I want. Once again, I remind myself - one step at a time!
Torque 3D Owner Matthew Langley
Torque