Creating an animated tilemap
by Chris · in Torque Game Builder · 03/07/2005 (6:39 pm) · 20 replies
I am looking to 1st learn how to create an animated imagemap. Second, I wish to take that image map and place it into a tilemap. (If this is possible).
I have begun to fool around with the whole tile-editor. I was able to open up the scroller.map to see how that was made and it is helping me quite a bit. I am confused as to how to change the player around. I have been trying to fiddle around and make it so there has to be some sort of land under the character you cant just move up-down-left-right without something being there. Any pointing to directions that could help me would also be helpful.
BTW I am really loving this torque 2d
I have begun to fool around with the whole tile-editor. I was able to open up the scroller.map to see how that was made and it is helping me quite a bit. I am confused as to how to change the player around. I have been trying to fiddle around and make it so there has to be some sort of land under the character you cant just move up-down-left-right without something being there. Any pointing to directions that could help me would also be helpful.
BTW I am really loving this torque 2d
About the author
#2
Hrm I have been reading about mouse events but I cant seem to get them to call.
Even something simple as that just doesnt echo "mouse move" when I move the mouse. I have been looking at the source code and found a scenewindow2d.setusemouse(true); which is suppost to "Sets whether mouses events are handled" That doesnt seem to work.
03/07/2005 (8:00 pm)
Great, thankyou very much Matt.Hrm I have been reading about mouse events but I cant seem to get them to call.
function sceneWindow2D::onMouseMove( %This, %Modifier, %WorldPosition, %MouseClicks )
{
echo("mouse move");
}Even something simple as that just doesnt echo "mouse move" when I move the mouse. I have been looking at the source code and found a scenewindow2d.setusemouse(true); which is suppost to "Sets whether mouses events are handled" That doesnt seem to work.
#3
just worked for me... hit the "~" tilde key and scroll up, do you see any red text ? if there are syntax errors it will flag them red in the console and run the previous runtime of that file
03/07/2005 (8:04 pm)
Hmm...function sceneWindow2D::onMouseMove( %This, %Modifier, %WorldPosition, %MouseClicks )
{
echo("Mouse Moved");
}just worked for me... hit the "~" tilde key and scroll up, do you see any red text ? if there are syntax errors it will flag them red in the console and run the previous runtime of that file
#4
03/07/2005 (8:07 pm)
Nope no errors. I cant figure it out for the life of me I have been scanning the source code and forums now for a good 45 mins looking to see if there possibly is something wrong that I am doing.
#5
03/07/2005 (8:10 pm)
Copy and paste all the code a few lines (or functions) before and after it and I'll see what I can find
#6
I have it currently in player.cs
Note my mousePosition(); function doesn't work either.
I get an error "fxSceneWindow2D::getMousePosition() - Window not attached to canvas!" so I recieve a 0 0 echo from it.
03/07/2005 (8:14 pm)
$movementSpeed = 30;
$playerFireSpeed = 100;
$playerFireRate = 200;
$playerFireType = 1;
$playerMaxFireType = 4;
$playerHelpers = 0;
$playerDead = false;
$playerScore = 0;
$playerWaitUpgrade = 7000;
//-----------------------------------------------------------------------------
// Player State.
//-----------------------------------------------------------------------------
// Mouse Move.
function mousePosition() {
%pos = sceneWindow2D.getMousePosition();
echo(%pos);
}
// Mouse Move.
sceneWindow2d.setusemouse(true);
function sceneWindow2D::onMouseMove( %This, %Modifier, %WorldPosition, %MouseClicks )
{
UpdatePlayer( %WorldPosition );
}
// Click and Drag.
function sceneWindow2D::onMouseDragged( %This, %Modifier, %WorldPosition, %MouseClicks ) {
UpdatePlayer( %WorldPosition );
}
// Update Player.
function UpdatePlayer( %WorldPosition )
{
myPlayer.setPosition( %WorldPosition );
}
// ----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Setup Player.
//-----------------------------------------------------------------------------
function setupPlayer()
{
// Create Player.
createPlayer();
// Reset Player Score.
resetPlayerScore();
// Setup Player Controls.
setupPlayerControls();
// Setup Upgrades.
schedule( $playerWaitUpgrade + getRandom()*5000, 0, "setupUpgrades" );
}I have it currently in player.cs
Note my mousePosition(); function doesn't work either.
I get an error "fxSceneWindow2D::getMousePosition() - Window not attached to canvas!" so I recieve a 0 0 echo from it.
#7
03/07/2005 (8:23 pm)
One other thing you might try, if you haven't already, is delete the .dso file with the same name... so I'd assume its edit: player.dso... this forces it to compile another .dso (rarely it will not do this for a reason or another even if not syntax errors)
#8
03/07/2005 (8:26 pm)
Hrm yeap deleted the dso and nothing has changed. Do you think it could just be some fluke thing and by just re-unziping the T2D SDK to the directory could possibly fix it?
#9
03/07/2005 (8:28 pm)
Worth a shot... though usually if thats the case then its just some stray line that screws it up lol... I do it all the time
#10
03/07/2005 (8:37 pm)
I think that is a good idea that way you can apply these scripts to stock T2D
#11
03/07/2005 (8:49 pm)
Even with a new installation it isnt working. Hrm maybe my computer is starting to dislike me or something...
#12
EDIT: even when I copy all the code you pasted without changing a single thing the mouse moved still works it just errors on the calls (obviously cause I don't have the rest of the objects :) ) though it still works.. must be something in some other set of code
03/07/2005 (8:52 pm)
Try a new instalation and just copying over the onMouseMove function, replacing it with a basic echo()... even using your syntax I got it to workEDIT: even when I copy all the code you pasted without changing a single thing the mouse moved still works it just errors on the calls (obviously cause I don't have the rest of the objects :) ) though it still works.. must be something in some other set of code
#13
EDIT: Ok there my idea of what is wrong is that I am defining the onMouseMove function in a bad area. My sceneWindow2D is an object. Is this function defined by default in any scripts that come with T2D. I have searched and couldn't find it so im assume there isn't. I am desperate and am trying anything that could possibly wrong. Besides the stock script all I have added to spacescroller/main.cs was
03/07/2005 (9:36 pm)
I have tried yet another clean installation and no such luck. I cant figure it out. I have installed it in a clean slate 3 times now, used most basic onMouseMove function and I can get it to echo my "mouse moved" thing. Anyone else have any ideas of what is up? I bet its some simple error... *sigh*EDIT: Ok there my idea of what is wrong is that I am defining the onMouseMove function in a bad area. My sceneWindow2D is an object. Is this function defined by default in any scripts that come with T2D. I have searched and couldn't find it so im assume there isn't. I am desperate and am trying anything that could possibly wrong. Besides the stock script all I have added to spacescroller/main.cs was
// Mouse Move.
sceneWindow2d.setusemouse(0);
function sceneWindow2D::onMouseMove( %This, %Modifier, %WorldPosition, %MouseClicks )
{
echo(sceneWindow2D.getMousePosition());
}right at the very top. That is it. Maybe someone else can try this on their computer on a clean slate?
#14
when you reinstall the SDK do you install it to the same directory ?
03/07/2005 (9:55 pm)
Try taking the setusemouse off (mine works with it and without it)....when you reinstall the SDK do you install it to the same directory ?
#15
03/07/2005 (10:05 pm)
I first deleted the old directory. So that should not be doing anything., I have tried it with setusemouse as true, false, and have even deleted the setusemouse. All the same.
#16
03/07/2005 (11:16 pm)
Wow this really is a stumper, no error messages at all in console ?
#18
Odd... I have NO clue as to why this is.
03/07/2005 (11:51 pm)
Dear god I got good news! After much trial and error I got it to work. Now my question is why on earth this is effecting anything but I use to have it in the spacescroller/main.cs once i took the code and placed it in the t2d/main.cs it worked!Odd... I have NO clue as to why this is.
#19
The "sceneWindow2D" is an object created in the base T2D directory. You should only really use it there.
BTW: Love your idea of doing a pirates game. T2D definately needs a pirates game, especially if you've got sea combat.
- Melv.
03/08/2005 (12:31 am)
@Christopher: Little confused over here on exactly what you're doing. You don't really need to mess with any of the "main.cs" files when you start.The "sceneWindow2D" is an object created in the base T2D directory. You should only really use it there.
BTW: Love your idea of doing a pirates game. T2D definately needs a pirates game, especially if you've got sea combat.
- Melv.
#20
now you had it in spacescroller/main.cs.... and were running the T2D app ? by default if you run the T2D application it runs all the files under the "T2D" folder... you can change the default mod directory in main.cs or just run the exe with "-mod folder" like "-mod spacescroller"
though definately should keep things out of main.cs (except later if you change something thats already handled there)... and keep it in the base directory , like /T2D/...
but just reiterating what Melv said...
glad its working lol it was just past midnight and I was packing for GDC when I was trying to help you, so wasn't all there :)... btw love your idea for a pirates game too! if you need someone to test I'll definately be happy to down the road.
03/08/2005 (8:10 am)
Glad you got it working !now you had it in spacescroller/main.cs.... and were running the T2D app ? by default if you run the T2D application it runs all the files under the "T2D" folder... you can change the default mod directory in main.cs or just run the exe with "-mod folder" like "-mod spacescroller"
though definately should keep things out of main.cs (except later if you change something thats already handled there)... and keep it in the base directory , like /T2D/...
but just reiterating what Melv said...
glad its working lol it was just past midnight and I was packing for GDC when I was trying to help you, so wasn't all there :)... btw love your idea for a pirates game too! if you need someone to test I'll definately be happy to down the road.
Torque 3D Owner Matthew Langley
Torque
here I have an example of an animated sprite :) once you do that loading it to a tilemap is the same as any other imagemap
welcome to the Torque 2D World & Community !
note: its number 6... and much easier to click the .html file linked at top to navigate