-SOLVED - Spine Slow down 2 or more sipnes = Resource Hungry
by Spinalkord · in Torque 2D Beginner · 09/25/2013 (7:33 pm) · 11 replies
Hi Everyone,
I have created a spine object in my project, everything runs fine but when I add more than 2 spine objects the whole program slows right down. I don't know why this is happening. could any one please help me? I have looked at the spineToy example and I cant work out what is different to my code.
powerUpTest.cs
main.cs
guiprofile.cs
scenewindow.cs
scene.cs
powerup.asset.taml
Any help would be greate ^_^
I have created a spine object in my project, everything runs fine but when I add more than 2 spine objects the whole program slows right down. I don't know why this is happening. could any one please help me? I have looked at the spineToy example and I cant work out what is different to my code.
powerUpTest.cs
function createPowerup(%pX,%py)
{
%powerup = new SkeletonObject();
%powerup.Asset ="root:powerup";
%powerup.setAnimation("Animation",true);
%powerup.position = %px SPC %py;
%powerup.SceneLayer=20;
%powerup.SkeletonScale=0.025;
%powerup.setSkeletonOffset(0,-5);
myScene.add(%powerup);
}main.cs
function root::create(%this)
{
exec("./gui/guiprofile.cs");
exec("./scripts/scenewindow.cs");
exec("./scripts/scene.cs");
exec("./scripts/bg.cs");
exec("./scripts/powerUpTest.cs");
createSceneWindow();
createScene();
createBackground();
createPowerUp(-10,20);
createPowerUp(-10,20);
createPowerUp(-50,20);
}
function root::destroy(%this)
{
echo("destroy");
destroySceneWindow();
}guiprofile.cs
if(!isObject(GuiDefaultProfile)) new GuiControlProfile(GuiDefaultProfile);
scenewindow.cs
function createSceneWindow()
{
if(!isObject(mySceneWindow))
{
new SceneWindow(mySceneWindow);
mySceneWindow.Profile=GuiDefaultProfile;
Canvas.setContent( mySceneWindow );
}
// Set camera to a canonical state.
%allBits = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31";
mySceneWindow.stopCameraMove();
mySceneWindow.dismount();
mySceneWindow.setViewLimitOff();
mySceneWindow.setRenderGroups( %allBits );
mySceneWindow.setRenderLayers( %allBits );
mySceneWindow.setObjectInputEventGroupFilter( %allBits );
mySceneWindow.setObjectInputEventLayerFilter( %allBits );
mySceneWindow.setLockMouse( true );
mySceneWindow.setCameraPosition( 0, 0 );
mySceneWindow.setCameraSize( 100, 75 );
mySceneWindow.setCameraZoom( 1 );
mySceneWindow.setCameraAngle( 0 );
}
function destroySceneWindow()
{
if(!isObject(mySceneWindow))
return;
mySceneWindow.delete();
}scene.cs
function createScene()
{
if(!isObject(myScene))
destroyScene();
new Scene(myScene);
setSceneToWindow();
}
function destroyScene()
{
if(!isObject(myScene))
return;
myScene.delete();
}
function setSceneToWindow()
{
// Sanity!
if ( !isObject(myScene) )
{
error( "Cannot set Sandbox Scene to Window as the Scene is invalid." );
return;
}
// Set scene to window.
mySceneWindow.setScene( myScene );
// Set camera to a canonical state.
%allBits = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31";
mySceneWindow.stopCameraMove();
mySceneWindow.dismount();
mySceneWindow.setViewLimitOff();
mySceneWindow.setRenderGroups( %allBits );
mySceneWindow.setRenderLayers( %allBits );
mySceneWindow.setObjectInputEventGroupFilter( %allBits );
mySceneWindow.setObjectInputEventLayerFilter( %allBits );
mySceneWindow.setLockMouse( true );
mySceneWindow.setCameraPosition( 0, 0 );
mySceneWindow.setCameraSize( 100, 75 );
mySceneWindow.setCameraZoom( 1 );
mySceneWindow.setCameraAngle( 0 );
// Update the toolbox options.
//updateToolboxOptions();
// reset the sandbox manipulation modes.
//Sandbox.resetManipulationModes();
}powerup.asset.taml
<SkeletonAsset
AssetName="powerup"
AtlasFile="powerup.atlas"
SkeletonFile="powerup.json"/>Any help would be greate ^_^
#2
Spine implementation is not finalized at the moment and features some weird bugs even though the basic functionality is functional.
09/25/2013 (8:48 pm)
The first thing that comes to mind is to make sure that you are not running the engine in Debug mode.Spine implementation is not finalized at the moment and features some weird bugs even though the basic functionality is functional.
#3
09/25/2013 (9:08 pm)
Not in debug. The spine toy example works fine.
#4
09/26/2013 (12:06 pm)
That's weird because the SpineToy has two powerups and does not have a performance hit. Are you using the exact same assets from the SpineToy?
#5
09/26/2013 (10:45 pm)
Yes I am. No modifications. When I add more assets in the SpineToy it works fine and there is no slow down. So its very weird. Have you tried my code? is my folder setup correct? do I need to use the preferences?
#6
09/27/2013 (6:47 am)
Maybe try not creating the first two right on top of each other - I don't know if you have collision set up but if you do it might be having a fit....
#7
09/27/2013 (12:41 pm)
Tried that. Everything works fine in sandbox spinetoy. Just not in my own scene. I can figure out what I have done wrong with my code -_-
#8
09/29/2013 (2:04 am)
Anyone have any luck using my code yet? I really want to use spine. I might just have to settle for just no more than 2 spine objects at this point in time :(
#9
should be %px.
How about changing
to:
09/29/2013 (5:20 am)
First inconsistancyfunction createPowerup(%pX,%py)
should be %px.
How about changing
function createScene()
{
if(!isObject(myScene)to:
function createScene()
{
if(isObject(myScene))
#10
09/29/2013 (7:31 pm)
Yeah Tried that... No Luck. I notice that with one SpineObject the scene eventually slows down. Some something is not right??? Cant quite pick it though.
#11
Thanks all for you help though.
Note to self. when using spine don't trace everything that happens lol.
10/05/2013 (8:18 pm)
Becuase I was tracing everything in the console log it was bogging down with reporting. lol I disabled the trace for everything and now it works fine ^_^ YAY Silly Mistake. Cant believe it took this long to solve. Thanks all for you help though.
Note to self. when using spine don't trace everything that happens lol.
Spinalkord