浏览代码

Asset Manager Loading

Got the Asset Manager to load on switching to the tab. Fixed a few other bugs with the toys.
Peter Robinson 4 年之前
父节点
当前提交
eee423b444

+ 4 - 2
editor/AssetAdmin/AssetAdmin.cs

@@ -99,10 +99,12 @@ function AssetAdmin::destroy(%this)
 
 function AssetAdmin::open(%this)
 {
-	//%this.Dictionary["ImageAsset"].load();
+	%this.Dictionary["ImageAsset"].load();
+	%this.Dictionary["AnimationAsset"].load();
 }
 
 function AssetAdmin::close(%this)
 {
-	//%this.Dictionary["ImageAsset"].unload();
+	%this.Dictionary["ImageAsset"].unload();
+	%this.Dictionary["AnimationAsset"].unload();
 }

+ 4 - 6
editor/AssetAdmin/AssetDictionary.cs

@@ -35,8 +35,6 @@ function AssetDictionary::onAdd(%this)
 	};
 	ThemeManager.setProfile(%this.grid, "emptyProfile");
 	%this.add(%this.grid);
-
-	%this.load();
 }
 
 function AssetDictionary::load(%this)
@@ -97,7 +95,6 @@ function AssetDictionary::load(%this)
 					Position = "0 0";
 				};
 				ThemeManager.setProfile(%texture, "spriteProfile");
-				%button.add(%texture);
 				if(%this.Type $= "ImageAsset")
 				{
 					%texture.setImage(%assetID);
@@ -107,6 +104,7 @@ function AssetDictionary::load(%this)
 					%texture.setAnimation(%assetID);
 					AssetDatabase.releaseAsset(%animationAsset.getImage());
 				}
+				%button.add(%texture);
 			}
 		}
 	}
@@ -116,10 +114,10 @@ function AssetDictionary::load(%this)
 function AssetDictionary::unload(%this)
 {
 	//Remove all the child gui controls
-	for(%i = %this.getCount() - 1; %i >= 0; %i++)
+	for(%i = %this.grid.getCount() - 1; %i >= 0; %i--)
 	{
-		%obj = %this.getObject(%i);
-		%obj.safeDelete();
+		%obj = %this.grid.getObject(%i);
+		%obj.delete();
 	}
 
 	//release all the assets we loaded for this - might take them out of memory

+ 0 - 4
engine/source/gui/containers/guiTabBookCtrl.cc

@@ -157,10 +157,6 @@ void GuiTabBookCtrl::onChildAdded( GuiControl *child )
    calculatePageTabs();
 
    child->resize( mPageRect.point, mPageRect.extent );
-
-
-   // Select this Page
-   selectPage( page );
 }
 
 

+ 13 - 13
toybox/DeathBallToy/1/main.cs

@@ -79,7 +79,7 @@ function DeathBallToy::reset(%this)
 
     // Limit the camera to the four sections of the desert
     SandboxWindow.setViewLimitOn( DeathBallToy.WorldLeft, DeathBallToy.WorldBottom, DeathBallToy.WorldRight, DeathBallToy.WorldTop );
-    
+
     // Add backgrounds
     %this.createDesertBackgrounds();
 
@@ -196,12 +196,12 @@ function DeathBallToy::spawnDeathball(%this, %position)
         maxSpeed = "15";
         CollisionCallback = true;
     };
-    
+
     %db.createCircleCollisionShape(8);
     %dealsDamageBehavior = DealsDamageBehavior.createInstance();
     %dealsDamageBehavior.initialize(100, false);
     Deathball.addBehavior(%dealsDamageBehavior);
-    
+
     //%db.pauseAnimation(1);
 
     Deathball.rollSchedule = Deathball.schedule(100, "updateRollAnimation");
@@ -217,7 +217,7 @@ function Deathball::updateRollAnimation(%this)
 {
     %this.rollSchedule = "";
 
-    %velocity = %this.getLinearVelocity();    
+    %velocity = %this.getLinearVelocity();
     %scaledVelocity = VectorLen(%velocity); // (mAbs(getWord(%velocity, 0))) + mAbs(getWord(%velocity, 1)) / 50;
     %flooredVelocity = mFloatLength(%scaledVelocity, 1);
 
@@ -242,10 +242,10 @@ function DeathBallToy::generateSoldierTemplate(%this)
     };
 
     %soldier.createPolygonBoxCollisionShape(5, 8);
-    
+
     // Return it to the toy
     %this.soldierTemplate = %soldier;
-    
+
     SandboxScene.add(%this.soldierTemplate);
 
     // Disable it
@@ -254,15 +254,15 @@ function DeathBallToy::generateSoldierTemplate(%this)
     // Add the behaviors
     %takesDamageBehavior = TakesDamageBehavior.createInstance();
     %takesDamageBehavior.initialize(1, "", "", "DeathBallToy:soldierDeathAnim", false);
-    
+
     %moveTowardBehavior = MoveTowardBehavior.createInstance();
-    
+
     %adjustedSpeed = DeathBallToy.soldierSpeed / DeathBallToy.maxSoldierSpeed;
     %moveTowardBehavior.initialize(Deathball, %adjustedSpeed);
-    
+
     %faceObjectBehavior = FaceObjectBehavior.createInstance();
     %faceObjectBehavior.initialize(Deathball, 0, 0);
-    
+
     %soldier.addBehavior(%takesDamageBehavior);
     %soldier.addBehavior(%moveTowardBehavior);
     %soldier.addBehavior(%faceObjectBehavior);
@@ -469,17 +469,17 @@ function DeathBallToy::onTouchUp(%this, %touchID, %worldPosition)
 {
     %origin = Deathball.getPosition();
     %angle = mAtan( Vector2Sub( %worldPosition, %origin ) );
-    
+
     // Since the speed is used instead of time, we can use the current velocity to set it's speed.
     %adjustedSpeed = VectorLen(DeathBall.getLinearVelocity());// (DeathBallToy.ballSpeed / DeathBallToy.maxBallSpeed) * 3000;
-   
+
     Deathball.MoveTo( %worldPosition, %adjustedSpeed, true, false );
 }
 
 //-----------------------------------------------------------------------------
 
 function DeathBallToy::onTouchDragged(%this, %touchID, %worldPosition)
-{    
+{
     %origin = Deathball.getPosition();
     %angle = mAtan( Vector2Sub( %worldPosition, %origin ) ) - 90;
 

+ 5 - 4
toybox/DeathBallToy/1/scripts/faceObjectBehavior.cs

@@ -40,10 +40,11 @@ function FaceObjectBehavior::updateFace(%this)
 {
     if (!isObject(%this.target) || !%this.owner.active)
         return;
-   
+
     %origin = %this.owner.getPosition();
     %angle = mAtan( Vector2Sub( %this.target.getPosition(), %origin ) );
-    
+	%angle -= 90;
+
     if ( %this.turnSpeed > 0.0 )
     {
         %this.owner.rotateTo(%angle, %this.turnSpeed);
@@ -52,7 +53,7 @@ function FaceObjectBehavior::updateFace(%this)
     {
         %this.owner.setAngle(%angle);
     }
-    
-      
+
+
     %this.schedule(200, updateFace);
 }

+ 142 - 137
toybox/SpriteStressToy/1/main.cs

@@ -24,16 +24,16 @@ function SpriteStressToy::create( %this )
 {
     // Set the sandbox drag mode availability.
     Sandbox.allowManipulation( pan );
-    
+
     // Set the manipulation mode.
     Sandbox.useManipulation( pan );
-    
+
     // Turn-off the full metrics.
     setMetricsOption( false );
-    
+
     // Turn-on the FPS metrics only.
     setFPSMetricsOption( true );
-    
+
     // Configure the toy.
     SpriteStressToy.SpriteSceneLayer = 10;
     SpriteStressToy.MaxSprite = 100;
@@ -43,15 +43,15 @@ function SpriteStressToy::create( %this )
     SpriteStressToy.RandomAngle = false;
     SpriteStressToy.RenderMode = "Static";
     SpriteStressToy.RenderSortMode = "off";
-    
+
     // Add the configuration options.
     addNumericOption("Sprite Maximum", 1, 100000, 100, "setSpriteMaximum", SpriteStressToy.MaxSprite, true, "Sets the maximum number of sprites to create." );
     addNumericOption("Sprite Size", 1, 75, 1, "setSpriteSize", SpriteStressToy.SpriteSize, true, "Sets the size of the sprites to create." );
-    addFlagOption("Random Angle", "setSpriteRandomAngle", SpriteStressToy.RandomAngle, true, "Whether to place the sprites at a random angle or not." );    
+    addFlagOption("Random Angle", "setSpriteRandomAngle", SpriteStressToy.RandomAngle, true, "Whether to place the sprites at a random angle or not." );
     addNumericOption("Sprite Create Period (ms)", 10, 1000, 10, "setSpriteCreatePeriod", SpriteStressToy.SpriteCreatePeriod, true, "Sets the time interval for creating bursts of sprites.  Bigger values create the maximum sprites quicker." );
     addSelectionOption( "Static,Static (Composite),Animated,Animated (Composite)", "Render Mode", 4, "setRenderMode", true, "Sets the type of object used in the stress test." );
     addSelectionOption( "Off,New,Old,X,Y,Z,-X,-Y,-Z", "Render Sort Mode", 9, "setRenderSortMode", false, "Sets the render sorting mode controlling the order of rendering." );
-    
+
     // Reset the toy.
     SpriteStressToy.reset();
 }
@@ -70,60 +70,60 @@ function SpriteStressToy::reset( %this )
     SpriteStressToy.SpriteCount = 0;
 
     // Calculate sprite bounds.
-    SpriteStressToy.HalfSize = SpriteStressToy.SpriteSize * 0.5;    
+    SpriteStressToy.HalfSize = SpriteStressToy.SpriteSize * 0.5;
     SpriteStressToy.MinX = -50 + SpriteStressToy.HalfSize;
-    SpriteStressToy.MaxX = 50 - SpriteStressToy.HalfSize;    
+    SpriteStressToy.MaxX = 50 - SpriteStressToy.HalfSize;
     SpriteStressToy.MinY = -37.5 + SpriteStressToy.HalfSize;
-    SpriteStressToy.MaxY = 37.5 - SpriteStressToy.HalfSize;    
-                
+    SpriteStressToy.MaxY = 37.5 - SpriteStressToy.HalfSize;
+
     // Clear the scene.
     SandboxScene.clear();
 
     // Update the render sort mode.
     %this.updateRenderSortMode();
-                  
+
     // Create background.
     %this.createBackground();
-            
+
     // Create sprite count overlay.
     %this.createSpriteCountOverlay();
-    
+
     // Handle static sprites.
     if ( SpriteStressToy.RenderMode $= "Static" )
     {
         // Create the static sprites.
         SpriteStressToy.startTimer( "createStaticSprites", SpriteStressToy.SpriteCreatePeriod );
-        
+
         return;
     }
-    
+
     // Handle static composite sprites.
     if ( SpriteStressToy.RenderMode $= "Static (Composite)" )
     {
         // Create the static composite sprites.
         SpriteStressToy.startTimer( "createStaticCompositeSprites", SpriteStressToy.SpriteCreatePeriod );
-    
+
         return;
     }
-    
+
     // Handle animated sprites.
     if ( SpriteStressToy.RenderMode $= "Animated" )
     {
         // Create the animated sprites.
         SpriteStressToy.startTimer( "createAnimatedSprites", SpriteStressToy.SpriteCreatePeriod );
-    
+
         return;
-    }    
-    
+    }
+
     // Handle animated composite sprites.
     if ( SpriteStressToy.RenderMode $= "Animated (Composite)" )
     {
         // Create the animated composite sprites.
         SpriteStressToy.startTimer( "createAnimatedCompositeSprites", SpriteStressToy.SpriteCreatePeriod );
-    
+
         return;
-    }    
-    
+    }
+
     // Error.
     error( "SpriteStressToy::reset() - Unknown render mode." );
 }
@@ -131,84 +131,89 @@ function SpriteStressToy::reset( %this )
 //-----------------------------------------------------------------------------
 
 function SpriteStressToy::createBackground( %this )
-{    
+{
     // Create the sprite.
     %object = new Scroller();
-    
+
     // Set the sprite as "static" so it is not affected by gravity.
     %object.setBodyType( static );
-       
+
     // Always try to configure a scene-object prior to adding it to a scene for best performance.
 
     // Set the position.
     %object.Position = "0 0";
 
-    // Set the size.        
+    // Set the size.
     %object.Size = "100 75";
-    
+
     // Set to the furthest background layer.
     %object.SceneLayer = 31;
-    
+
     // Set an image.
     %object.Image = "ToyAssets:checkered";
     %object.ScrollX = 4;
     %object.ScrollY = 3;
     %object.RepeatX = 4;
     %object.RepeatY = 3;
-    
+
     // Set the blend color.
     %object.BlendColor = LightSteelBlue;
-            
+
     // Add the sprite to the scene.
-    SandboxScene.add( %object );    
+    SandboxScene.add( %object );
 }
 
 //-----------------------------------------------------------------------------
 
 function SpriteStressToy::createSpriteCountOverlay( %this )
-{    
-    // Create the image font.
-    %object = new ImageFont();
+{
+    // Create the text sprite.
+    %object = new TextSprite();
 
-    // Set the overlay font object.    
+    // Set the overlay font object.
     SpriteStressToy.OverlayFontObject = %object;
-    
+
     // Set the sprite as "static" so it is not affected by gravity.
     %object.setBodyType( static );
-       
+
     // Always try to configure a scene-object prior to adding it to a scene for best performance.
 
-    // Set the position.
-    %object.Position = "-50 -35";
+    // Set the position and size.
+    %object.Position = "-45 -35";
+	%object.Size = "5 2.5";
 
-    // Set the size.        
-    %object.FontSize = 2;
+    // Set the size.
+    %object.FontSize = 2.2;
 
     // Set the text alignment.
     %object.TextAlignment = Left;
-        
+
     // Set to the nearest layer.
     %object.SceneLayer = 0;
-    
+
     // Set a font image.
-    %object.Image = "ToyAssets:fancyFont";
-    
+    %object.Font = "ToyAssets:ArialFont";
+
+	//Set the overflow Modes
+	%object.OverflowModeX = "Visible";
+	%object.OverflowModeY = "Visible";
+
     // Set the blend color.
     %object.BlendColor = White;
-                
+
     // Add the sprite to the scene.
-    SandboxScene.add( %object );  
-    
+    SandboxScene.add( %object );
+
     // Update the overlay.
-    %this.updateSpriteCountOverlay();  
+    %this.updateSpriteCountOverlay();
 }
 
 //-----------------------------------------------------------------------------
 
 function SpriteStressToy::updateSpriteCountOverlay( %this )
-{    
+{
     // Update sprite count overlay.
-    SpriteStressToy.OverlayFontObject.Text = SpriteStressToy.SpriteCount;    
+    SpriteStressToy.OverlayFontObject.Text = SpriteStressToy.SpriteCount;
 }
 
 //-----------------------------------------------------------------------------
@@ -216,14 +221,14 @@ function SpriteStressToy::updateSpriteCountOverlay( %this )
 function SpriteStressToy::updateRenderSortMode( %this )
 {
     // Set the sprite layer sort mode.
-    SandboxScene.setLayerSortMode( SpriteStressToy.SpriteSceneLayer, SpriteStressToy.RenderSortMode );  
-    
+    SandboxScene.setLayerSortMode( SpriteStressToy.SpriteSceneLayer, SpriteStressToy.RenderSortMode );
+
     // Finish if no composite-sprite object.
     if ( !isObject(SpriteStressToy.CompositeSpriteObject) )
         return;
-        
+
     // Set the batch sort mode.
-    SpriteStressToy.CompositeSpriteObject.SetBatchSortMode( SpriteStressToy.RenderSortMode );        
+    SpriteStressToy.CompositeSpriteObject.SetBatchSortMode( SpriteStressToy.RenderSortMode );
 }
 
 //-----------------------------------------------------------------------------
@@ -235,16 +240,16 @@ function SpriteStressToy::createStaticSprites( %this )
     {
         // Stop the timer.
         SpriteStressToy.stopTimer();
-        
+
         return;
     }
-        
+
     // Create the sprites at the specified rate.
     for( %n = 0; %n < SpriteStressToy.SpriteCreateRate; %n++ )
-    {        
+    {
         // Create the sprite.
         %object = new Sprite();
-                
+
         // Always try to configure a scene-object prior to adding it to a scene for best performance.
 
         // The sprite is static i.e. it won't move.
@@ -255,44 +260,44 @@ function SpriteStressToy::createStaticSprites( %this )
 
         // Set to just in-front of the background layer.
         %object.SceneLayer = SpriteStressToy.SpriteSceneLayer;
-        
+
         // Set a random scene-layer depth.
         %object.SceneLayerDepth = getRandom(-100,100);
 
-        // Set the size of the sprite.            
+        // Set the size of the sprite.
         %object.Size = SpriteStressToy.SpriteSize;
-        
+
         // Set a random angle if selected.
         if ( SpriteStressToy.RandomAngle )
             %object.Angle = getRandom(0,360);
-               
+
         // Set the sprite to use an image.  This is known as "static" image mode.
         %object.Image = "ToyAssets:TD_Knight_CompSprite";
-        
+
         // We don't really need to do this as the frame is set to zero by default.
         %object.Frame = getRandom(0,63);
-            
+
         // Add the sprite to the scene.
         SandboxScene.add( %object );
-        
+
         // Increase sprite count.
         SpriteStressToy.SpriteCount++;
-        
+
         // Finish if max sprites reached.
         if ( SpriteStressToy.SpriteCount == SpriteStressToy.MaxSprite )
         {
             // Update the overlay.
             %this.updateSpriteCountOverlay();
-            
+
             // Stop the timer.
-            SpriteStressToy.stopTimer();         
-            
+            SpriteStressToy.stopTimer();
+
             return;
         }
     }
-    
+
     // Update the overlay.
-    %this.updateSpriteCountOverlay();  
+    %this.updateSpriteCountOverlay();
 }
 
 //-----------------------------------------------------------------------------
@@ -304,16 +309,16 @@ function SpriteStressToy::createAnimatedSprites( %this )
     {
         // Stop the timer.
         SpriteStressToy.stopTimer();
-        
+
         return;
     }
 
     // Create the sprites at the specified rate.
     for( %n = 0; %n < SpriteStressToy.SpriteCreateRate; %n++ )
-    {           
+    {
         // Create the sprite.
         %object = new Sprite();
-        
+
         // Always try to configure a scene-object prior to adding it to a scene for best performance.
 
         // The sprite is static i.e. it won't move.
@@ -321,44 +326,44 @@ function SpriteStressToy::createAnimatedSprites( %this )
 
         // Set the position.
         %object.Position = getRandom(SpriteStressToy.MinX, SpriteStressToy.MaxX) SPC getRandom(SpriteStressToy.MinY, SpriteStressToy.MaxY);
-            
+
         // Set to just in-front of the background layer.
         %object.SceneLayer = SpriteStressToy.SpriteSceneLayer;
-            
+
         // Set a random scene-layer depth.
         %object.SceneLayerDepth = getRandom(-100,100);
-            
-        // Set the size of the sprite.            
+
+        // Set the size of the sprite.
         %object.Size = SpriteStressToy.SpriteSize;
 
         // Set a random angle if selected.
         if ( SpriteStressToy.RandomAngle )
             %object.Angle = getRandom(0,360);
-        
+
         // Set the sprite to use an animation.  This is known as "animated" image mode.
         %object.Animation = "ToyAssets:TD_Knight_MoveSouth";
-           
+
         // Add the sprite to the scene.
         SandboxScene.add( %object );
-                
+
         // Increase sprite count.
         SpriteStressToy.SpriteCount++;
-        
+
         // Finish if max sprites reached.
         if ( SpriteStressToy.SpriteCount == SpriteStressToy.MaxSprite )
         {
             // Update the overlay.
-            %this.updateSpriteCountOverlay();              
-            
+            %this.updateSpriteCountOverlay();
+
             // Stop the timer.
-            SpriteStressToy.stopTimer();         
-            
+            SpriteStressToy.stopTimer();
+
             return;
         }
     }
-    
+
     // Update the overlay.
-    %this.updateSpriteCountOverlay();  
+    %this.updateSpriteCountOverlay();
 }
 
 //-----------------------------------------------------------------------------
@@ -370,7 +375,7 @@ function SpriteStressToy::createStaticCompositeSprites( %this )
     {
         // Stop the timer.
         SpriteStressToy.stopTimer();
-        
+
         return;
     }
 
@@ -379,28 +384,28 @@ function SpriteStressToy::createStaticCompositeSprites( %this )
     {
         // No, so create it.
         %composite = new CompositeSprite();
-        
+
         // Set the composite object.
         SpriteStressToy.CompositeSpriteObject = %composite;
-        
+
         // The sprite is static i.e. it won't move.
         %composite.BodyType = static;
-           
+
         // Set the batch layout mode.  We must do this before we add any sprites.
         %composite.SetBatchLayout( "off" );
-                
+
         // Set the batch render isolation.
         %composite.SetBatchIsolated( SpriteStressToy.RenderSortMode );
 
         // Set to just in-front of the background layer.
         %composite.SceneLayer = SpriteStressToy.SpriteSceneLayer;
-                
+
         // Set the batch to not cull because the sprites are always on the screen
         // and it's faster and takes less memory.
         %composite.setBatchCulling( false );
-       
+
         // Add to the scene.
-        SandboxScene.add( %composite );        
+        SandboxScene.add( %composite );
     }
 
     // Fetch the composite object.
@@ -408,44 +413,44 @@ function SpriteStressToy::createStaticCompositeSprites( %this )
 
     // Create the sprites at the specified rate.
     for( %n = 0; %n < SpriteStressToy.SpriteCreateRate; %n++ )
-    { 
+    {
         // Add a sprite with no logical position.
         %composite.addSprite();
-        
+
         // Set the sprites location position to a random location.
         %composite.setSpriteLocalPosition( getRandom(SpriteStressToy.MinX, SpriteStressToy.MaxX), getRandom(SpriteStressToy.MinY, SpriteStressToy.MaxY) );
-                
+
         // Set a random size.
         %composite.setSpriteSize( SpriteStressToy.SpriteSize );
-        
+
         // Set a random angle.
         if ( SpriteStressToy.RandomAngle )
             %composite.setSpriteAngle( getRandom(0,360) );
 
         // Set the sprite to use an image.
-        %composite.setSpriteImage( "ToyAssets:TD_Knight_CompSprite", getRandom(0,63) );          
-        
+        %composite.setSpriteImage( "ToyAssets:TD_Knight_CompSprite", getRandom(0,63) );
+
         // Set a random depth.
-        %composite.SetSpriteDepth( getRandom( -100, 100 ) ); 
-                        
+        %composite.SetSpriteDepth( getRandom( -100, 100 ) );
+
         // Increase sprite count.
         SpriteStressToy.SpriteCount++;
-        
+
         // Finish if max sprites reached.
         if ( SpriteStressToy.SpriteCount == SpriteStressToy.MaxSprite )
         {
             // Update the overlay.
-            %this.updateSpriteCountOverlay();              
-            
+            %this.updateSpriteCountOverlay();
+
             // Stop the timer.
-            SpriteStressToy.stopTimer();         
-            
+            SpriteStressToy.stopTimer();
+
             return;
         }
     }
-    
+
     // Update the overlay.
-    %this.updateSpriteCountOverlay();  
+    %this.updateSpriteCountOverlay();
 }
 
 //-----------------------------------------------------------------------------
@@ -457,7 +462,7 @@ function SpriteStressToy::createAnimatedCompositeSprites( %this )
     {
         // Stop the timer.
         SpriteStressToy.stopTimer();
-        
+
         return;
     }
 
@@ -466,28 +471,28 @@ function SpriteStressToy::createAnimatedCompositeSprites( %this )
     {
         // No, so create it.
         %composite = new CompositeSprite();
-        
+
         // Set the composite object.
         SpriteStressToy.CompositeSpriteObject = %composite;
-        
+
         // The sprite is static i.e. it won't move.
         %composite.BodyType = static;
-           
+
         // Set the batch layout mode.  We must do this before we add any sprites.
         %composite.SetBatchLayout( "off" );
-                
+
         // Set the batch render isolation.
         %composite.SetBatchIsolated( SpriteStressToy.RenderSortMode );
 
         // Set to just in-front of the background layer.
         %composite.SceneLayer = SpriteStressToy.SpriteSceneLayer;
-                
+
         // Set the batch to not cull because the sprites are always on the screen
         // and it's faster and takes less memory.
         %composite.setBatchCulling( false );
-       
+
         // Add to the scene.
-        SandboxScene.add( %composite );        
+        SandboxScene.add( %composite );
     }
 
     // Fetch the composite object.
@@ -495,44 +500,44 @@ function SpriteStressToy::createAnimatedCompositeSprites( %this )
 
     // Create the sprites at the specified rate.
     for( %n = 0; %n < SpriteStressToy.SpriteCreateRate; %n++ )
-    { 
+    {
         // Add a sprite with no logical position.
         %composite.addSprite();
-        
+
         // Set the sprites location position to a random location.
         %composite.setSpriteLocalPosition( getRandom(SpriteStressToy.MinX, SpriteStressToy.MaxX), getRandom(SpriteStressToy.MinY, SpriteStressToy.MaxY) );
-                
+
         // Set a random size.
         %composite.setSpriteSize( SpriteStressToy.SpriteSize );
-        
+
         // Set a random angle.
         if ( SpriteStressToy.RandomAngle )
             %composite.setSpriteAngle( getRandom(0,360) );
 
         // Set the sprite to use an animation.
         %composite.setSpriteAnimation( "ToyAssets:TD_Knight_MoveSouth" );
-        
+
         // Set a random depth.
-        %composite.SetSpriteDepth( getRandom( -100, 100 ) ); 
-                        
+        %composite.SetSpriteDepth( getRandom( -100, 100 ) );
+
         // Increase sprite count.
         SpriteStressToy.SpriteCount++;
-        
+
         // Finish if max sprites reached.
         if ( SpriteStressToy.SpriteCount == SpriteStressToy.MaxSprite )
         {
             // Update the overlay.
-            %this.updateSpriteCountOverlay();              
+            %this.updateSpriteCountOverlay();
 
             // Stop the timer.
-            SpriteStressToy.stopTimer();         
-            
+            SpriteStressToy.stopTimer();
+
             return;
         }
     }
-    
+
     // Update the overlay.
-    %this.updateSpriteCountOverlay();  
+    %this.updateSpriteCountOverlay();
 }
 
 //-----------------------------------------------------------------------------
@@ -575,7 +580,7 @@ function SpriteStressToy::setRenderMode( %this, %value )
 function SpriteStressToy::setRenderSortMode( %this, %value )
 {
     SpriteStressToy.RenderSortMode = %value;
-    
+
     // Update the render sort mode.
-    %this.updateRenderSortMode();    
+    %this.updateRenderSortMode();
 }