Game Development Community

CreatePlayer function problem

by C. Benson · in Torque Game Builder · 07/07/2006 (12:30 pm) · 8 replies

I can't for the life of me get my createplayer function to cause the image to appear when I run project. I have tried the animated and static sprite creation methods from the platformer tutorial. neither work. I know I am doing something wrong but I thought I had followed the tutorial pretty explicitly. I am using the default running mannequin .png from the same tutorial which is definately named PlatformerPlayerAnimation.png and in the level builder as PlatformerPlayerAnimationImageMap.

//This is in game.cs
exec("./player.cs");
createPlayer();

//This is in player.cs
function createPlayer()
{
$player = new t2dStaticSprite()
{
scenegraph = t2dscene;
};
$player.setImageMap(PlatformerPlayerAnimationImageMap);

$player.setSize("80 80");
$player.setPosition("0 0");
}

//This is in datablocks.cs
new t2dImageMapDatablock(PlatformerPlayerAnimationImageMap) {
canSaveDynamicFields = "1";
imageName = "Testgame/data/images/PlatformerPlayerAnimation";
imageMode = "CELL";
frameCount = "-1";
filterMode = "SMOOTH";
filterPad = "1";
preferPerf = "0";
cellRowOrder = "1";
cellOffsetX = "0";
cellOffsetY = "0";
cellStrideX = "0";
cellStrideY = "0";
cellCountX = "-1";
cellCountY = "-1";
cellWidth = "128";
cellHeight = "128";
preload = "1";
allowUnload = "0";
};

#1
07/07/2006 (1:15 pm)
Go into the level editor. Choose the scene object and go to the edit tab. Make sure the name field has t2dscene in it. If not, put it there and save the level. Then give it a shot.
#2
07/07/2006 (10:26 pm)
I did exactly that and restarted and ran it a couple times. It still doesnt work. I've double checked the image name and it's still PlatformerPlayerAnimation and the image map is still PlatformerPlayerAnimationImageMap. I've tried changing the position and the size and still nothing. There is no other nonessential code running.
#3
07/09/2006 (12:32 am)
*very polite bump* :)

Are there any other possible mistakes I'm making? Is this a known issue?
#4
07/09/2006 (7:49 am)
Can you put the project somewhere and link it and then I'll take a look. My guess was that you just weren't pointing to the actualy scenegraph.
#5
07/10/2006 (5:12 pm)
Try changing
$player = new t2dStaticSprite()
{
scenegraph = t2dscene;
};

to

$player = new t2dStaticSprite()
{
scenegraph = SceneWindow2D.getScenegraph();
};
#6
07/13/2006 (6:41 am)
Well I am still completely unable to get this to work in my game. I have made a completely new project consisting of ONLY the above code (with all subsequent suggested changes). It still doesn't work.

Here is my project in a zip archive. If someone could take a look I'd be grateful.

http://gamingdead.com/createtest.zip
#7
07/13/2006 (7:11 am)
Move your createPlayer(); call to the bottom of startGame that way the level is loaded first. Your creating your player before you've loaded anything or pushed anything to the canvas.
#8
07/13/2006 (9:32 am)
Well. I'm an idiot. Thanks for your help.