Help! My scroller has fallen and can't get up!!
by Kevin James · in Torque Game Builder · 06/24/2010 (8:26 am) · 14 replies
Well, it can get up after I rebuild it, but it got your attention. Anyway, ever since I upgraded to 175, if I edit something in the same level where my Warp scroller exists, the scroller gets corrupted. And it doesn't show until I run the game or reopen that level. Its as if the scroller imagemap is zoomed in 1000%. To fix it, I can't just change the imagemap and change it back. I have to delete the scroller and rebuild it with all of the mountings. This is a major nuisance.
About the author
Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/
#2
06/24/2010 (10:08 am)
Thanks Patrick! I'll make that change ASAP. Would be nice if I didn't have to constantly rebuild it 5 times a day...
#3
06/24/2010 (10:50 am)
I bet. Is the scroller power of two? I've read about issues with it not being but I honestly haven't used them all that much - and not at all in 1.7.5.
#4
06/24/2010 (10:55 am)
Yes, it works fine right after I build it. And it stays fine as long as I never change anything on that level. I'm going to build this in script once and for all. I feel sorry for all those side scroller games that put their stuff together using the level editor.
#5
06/25/2010 (9:29 am)
I have this same issue, only once corrupted, nothing I do short of deleting the object and reinserting it onto the field will restore it to functioning condition.
#6
problem solved.
06/25/2010 (11:58 am)
Exactly. My problem went away after I took it out of the editor and created it in script:new t2dScroller(WarpShow) {
scenegraph = glMain;
imageMap = "warpBackgroundImageMap";
Position = "500 500";
size = "170 170";
Layer = "30";
};
WarpShip.mount(WarpShow,"0 0");problem solved.
#7
Thanks!
07/19/2010 (7:03 pm)
I know I am a little late, but I am having the exact same problem! Is there a way to fix it, without using the code? Thanks!
#8
07/20/2010 (6:33 pm)
This is something that started with 1.7.5. Thus I assume the fix requires a source code hack.
#9
10/23/2010 (10:56 pm)
I am having the same problem with my starfield. Guess i'll write it into code for now. Thanks Kevin.
#10
All this code is actually in my Ship Movement Behavior::
I call a function called initialize() in my onBehaviorAdd(%this) function that create 3 scrollers in layers 29,30 and 31:
new t2dScroller(stars1) {
scenegraph = SceneWindow2D.GetSceneGraph();
Visible = "1";
imageMap = "Starfield_CloseImageMap";
repeatX = "4";
repeatY = "2.50";
canSaveDynamicFields = "1";
Position = "-50.000 -50.0000";
size = "200.000 200.000";
Layer = "29";
mountID = "7";
};
Notice the repeatX,repeatY. I did this so the starfield will be twice the size of my camera so when rotating you wont see the edges.
Then in my behavior onUpdate() i call this:
stars1.setScrollPolar(shipPhysics.rotation, %this.BaseVelocity/%this.speedClosest);
Now 2tdscroller does have the setImpulseForcePolar() method but it applies tot he actual object and moves the object which is what we do not want. So When i created my starfields above i created a dummy static sprite to use for calculating the physics and grabbed the values and apply to the setScrollPolar() you see above.
Also in initialize() in my onBehaviorAdd(%this)
new t2dStaticSprite(shipPhysics) {
scenegraph = SceneWindow2D.GetSceneGraph();
frame = "0";
canSaveDynamicFields = "1";
size = "0.100 0.100";
Layer = "31";
WorldLimitMode = "NULL";
thrusters = "0";
};
and in my onUpdate()
//Move Ship
shipPhysics.setImpulseForcePolar(%this.owner.rotation, %this.BaseVelocity);
shipPhysics.setAngularVelocity(%this.BaseAngularVelocity);
//Set Ship object rotation to match our physics model
%this.owner.setRotation(shipPhysics.rotation);
I am going to release this as a public behavior. I just want to add some code to check for the 3 starfield imagemaps and an option to enable/disable them before doing so. So the next day or two you should see something in the behaviors section.
10/26/2010 (2:50 pm)
Hey Kevin. Here is some code snippets that I have working. Hope it helps.All this code is actually in my Ship Movement Behavior::
I call a function called initialize() in my onBehaviorAdd(%this) function that create 3 scrollers in layers 29,30 and 31:
new t2dScroller(stars1) {
scenegraph = SceneWindow2D.GetSceneGraph();
Visible = "1";
imageMap = "Starfield_CloseImageMap";
repeatX = "4";
repeatY = "2.50";
canSaveDynamicFields = "1";
Position = "-50.000 -50.0000";
size = "200.000 200.000";
Layer = "29";
mountID = "7";
};
Notice the repeatX,repeatY. I did this so the starfield will be twice the size of my camera so when rotating you wont see the edges.
Then in my behavior onUpdate() i call this:
stars1.setScrollPolar(shipPhysics.rotation, %this.BaseVelocity/%this.speedClosest);
Now 2tdscroller does have the setImpulseForcePolar() method but it applies tot he actual object and moves the object which is what we do not want. So When i created my starfields above i created a dummy static sprite to use for calculating the physics and grabbed the values and apply to the setScrollPolar() you see above.
Also in initialize() in my onBehaviorAdd(%this)
new t2dStaticSprite(shipPhysics) {
scenegraph = SceneWindow2D.GetSceneGraph();
frame = "0";
canSaveDynamicFields = "1";
size = "0.100 0.100";
Layer = "31";
WorldLimitMode = "NULL";
thrusters = "0";
};
and in my onUpdate()
//Move Ship
shipPhysics.setImpulseForcePolar(%this.owner.rotation, %this.BaseVelocity);
shipPhysics.setAngularVelocity(%this.BaseAngularVelocity);
//Set Ship object rotation to match our physics model
%this.owner.setRotation(shipPhysics.rotation);
I am going to release this as a public behavior. I just want to add some code to check for the 3 starfield imagemaps and an option to enable/disable them before doing so. So the next day or two you should see something in the behaviors section.
#11
10/28/2010 (12:14 pm)
Andrew, my problem was fixed by creating the scroller in code. Why would I bother with all of this extra complexity?
#13
04/20/2011 (5:27 am)
Same here. The reason is sourceRect feature, which does not work properly for the scrollers - sourceRect field gets corrupted after a couple of loads and saves, and useSourceRect field is completely ignored. Nice little addition to the set of all borked features we had before.
#14
The SourceRect is the fault and by setting them to "0 0 0 0" through script fixes the problem in the editor until the next time the scene is reloaded.
I have managed to automate this by amending the onload function.
In the file tgb\common\gameScripts\levelManagement.cs
Replace the function t2dSceneWindow::loadLevel with the one below and when the project is loaded into the editor, all t2dScroller objects will have their sourcerect auto set to "0 0 0 0".
Its not a fix but a good hack to work around it until it gets fixed correctly in an update.
O&O
.\_/
04/28/2011 (8:13 pm)
Well this has been bugging me for a while and has taken a few hrs to work out.The SourceRect is the fault and by setting them to "0 0 0 0" through script fixes the problem in the editor until the next time the scene is reloaded.
I have managed to automate this by amending the onload function.
In the file tgb\common\gameScripts\levelManagement.cs
Replace the function t2dSceneWindow::loadLevel with the one below and when the project is loaded into the editor, all t2dScroller objects will have their sourcerect auto set to "0 0 0 0".
Its not a fix but a good hack to work around it until it gets fixed correctly in an update.
function t2dSceneWindow::loadLevel(%sceneWindow, %levelFile)
{
// Clean up any previously loaded stuff.
%sceneWindow.endLevel();
// Load the level.
$useNewSceneGraph = true;
%scenegraph = %sceneWindow.addToLevel(%levelFile);
if (!isObject(%scenegraph))
return 0;
%sceneWindow.setSceneGraph(%scenegraph);
// Set the window properties from the scene graph if they are available.
%cameraPosition = %sceneWindow.getCurrentCameraPosition();
%cameraSize = t2dVectorSub(getWords(%sceneWindow.getCurrentCameraArea(), 2, 3),
getWords(%sceneWindow.getCurrentCameraArea(), 0, 1));
if (%scenegraph.cameraPosition !$= "")
%cameraPosition = %scenegraph.cameraPosition;
if (%scenegraph.cameraSize !$= "")
%cameraSize = %scenegraph.cameraSize;
%sceneWindow.setCurrentCameraPosition(%cameraPosition, %cameraSize);
// Only perform "onLevelLoaded" callbacks when we're NOT editing a level
//
// This is so that objects that may have script associated with them that
// the level builder cannot undo will not be executed while using the tool.
//
if (!$LevelEditorActive)
{
// Notify the scenegraph that it was loaded.
if( %scenegraph.isMethod( "onLevelLoaded" ) )
%scenegraph.onLevelLoaded();
// And finally, notify all the objects that they were loaded.
%sceneObjectList = %scenegraph.getSceneObjectList();
%sceneObjectCount = getWordCount(%sceneObjectList);
for (%i = 0; %i < %sceneObjectCount; %i++)
{
%sceneObject = getWord(%sceneObjectList, %i);
if( %sceneObject.isMethod( "onLevelLoaded" ) )
%sceneObject.onLevelLoaded(%scenegraph);
}
}
else
{
// Loop through all objects looking for any t2dScroller objects
%sceneObjectList = %scenegraph.getSceneObjectList();
%sceneObjectCount = getWordCount(%sceneObjectList);
for (%i = 0; %i < %sceneObjectCount; %i++)
{
%sceneObject = getWord(%sceneObjectList, %i);
%myclassname = %sceneObject.getClassName();
if (%myclassname $= "t2dScroller"){
//HACK - Set Source Rect to "0 0 0 0"
%sceneObject.setSourceRect("0", "0", "0", "0");
}
}
}
$lastLoadedScene = %scenegraph;
return %scenegraph;
}O&O
.\_/
Torque Owner RollerJesus
Dream. Build. Repeat.
Note: Fang: 1.5.2 - windowed mode.