xompl Posted March 14, 2014 Share Posted March 14, 2014 Hi, this is a quite open question because I am not sure what's the best way to implement this usingPhaser. I implemented a simple vertical shooter and I'd like to add a tiled background with trees, water, etc.As far as I know, using for this a tilemap requires an actual matrix with the map content. The game will usean extremelly narrow but potentially unlimited tile map so I though on creating one on the fly. What's the best way to implement this? In my current implementation create() populates the screen with 32x32 tiles and during the update() Imove all of them down to simulate the movement. When one row of tiles exits the window I move allthese tiles to the top.This might be reinventing the wheel but all the tilemap examples use a fixed map. I'm open to new ideas. My approach works but only if the speed of the movement is slow.If I use this.tiles[y][x].body.y += 1 all the tiles are nicely aligned but if I use a speed like 5 the rows of tiles are not aligned anymore. Not sure if its a bug in my code or sync problems between update and draw. Link to comment Share on other sites More sharing options...
rich Posted March 14, 2014 Share Posted March 14, 2014 Create the world in much bigger chunks? Like 200x200 tiles and only refresh when you hit the edge? Link to comment Share on other sites More sharing options...
xompl Posted March 15, 2014 Author Share Posted March 15, 2014 Sorry, not sure what you mean. You mean a single tilemap where the charater is moving vertically (say 1000 rows and 30 colums)and when the char is arriving to the end I copy the current tiles on screen to the first rows and movethe char to this position?I thought about this solution but I was not sure how smooth I could make this "teleportation". In my current implementation I use 30 lines of sprites/tiles. On screen there are at most 21 lines at the same time. Thanks for your help rich. I love Phaser! Link to comment Share on other sites More sharing options...
Recommended Posts