Non-automatic side-scrolling
by Allistair · in Torque Game Builder · 03/01/2006 (5:55 am) · 3 replies
Hey All,
I bet this question has been asked before, I'm really sorry, I did perform a search but I don't find it too effective :(
I am looking for advice on non-automatic side-scrolling. I've checked out the space shooter demo which has an auto panned scroller tile map. However I'm after a Mario-esque kind of situation, where the player sprite is pretty much in the middle of the screen and the camera moves along the background when the player moves. When the player reaches the extents of the map, the player sprite itself moves towards the edge of the screen ...
I am after some tips, hints, object names, code snippets, whatever you've got to get me on the right track. I have my sprite. I have it moving but I'd like to get it moving along a non-repeating background. Not sure whether I would draw one big background, or assemble a level from mini tiles along the way.
Can you tell I'm lost yet?!
I bet this question has been asked before, I'm really sorry, I did perform a search but I don't find it too effective :(
I am looking for advice on non-automatic side-scrolling. I've checked out the space shooter demo which has an auto panned scroller tile map. However I'm after a Mario-esque kind of situation, where the player sprite is pretty much in the middle of the screen and the camera moves along the background when the player moves. When the player reaches the extents of the map, the player sprite itself moves towards the edge of the screen ...
I am after some tips, hints, object names, code snippets, whatever you've got to get me on the right track. I have my sprite. I have it moving but I'd like to get it moving along a non-repeating background. Not sure whether I would draw one big background, or assemble a level from mini tiles along the way.
Can you tell I'm lost yet?!
About the author
#2
Some gotchas: If you are working with a tilemap, you will also need to make sure that each tilemap layer's size (set/getSize()) matches with the total size of the tile layer. Calculating this size is rather simple:
This is only important if you've changed the individual tile size manually via %layer.setTileSize();, but not a bad practice to make sure as you scroll through the tilemap you can see the entire map appropriately.
03/01/2006 (6:36 am)
Yep, it does! The specifics you need for getting your effect:// set up camera params that cannot be changed once camera is mounted
// example values, change prior to mounting the camera
sceneWindow2D.setCurrentCameraPosition("25 25 150 150");
sceneWindow2D.setCurrentCameraZoom($defaultCameraZoom);
// attaches camera to your player object
sceneWindow2D.mount($player, "0 0", "0 0", true);Some gotchas: If you are working with a tilemap, you will also need to make sure that each tilemap layer's size (set/getSize()) matches with the total size of the tile layer. Calculating this size is rather simple:
%layerTileSize = %layer.getTileSize(); // gives you x and y size %layerTileSizeX = getWord(%layerTileSize, 0); %layerTileSizeY = getWord(%layerTileSize, 1); %layerTileCount = %layer.getTileCount(); %layerTileCountX = getWord(%layerTileCount, 0); %layerTileCountY = getWord(%layerTileCount, 1); %layer.setSize( (%layerTileSizeX * %layerTileCountX), (%layerTileSizeY * %layerTileCountY) );
This is only important if you've changed the individual tile size manually via %layer.setTileSize();, but not a bad practice to make sure as you scroll through the tilemap you can see the entire map appropriately.
#3
03/01/2006 (3:00 pm)
Thanks for your time Stephen, I will try and put this into action :)
Torque Owner Allistair
http://tdn.garagegames.com/wiki/Torque_2D/GenreTutorials/PlatformerCamera