Scrolling the tilemap by user movement
Hi Selim,
I have a position problem with my player sprite after the tilemap has scrolled. Here is my code: http://lortschi.de/games/bd/
The playground is smaller created as the tilemap. So I can move the tilemap in the opposing direction when the player reached at a certain point on the map. In this case is the 800px mark. In my code is this the scrollStage function at line 196.
The curios problem after the map movement is, that my player sprite position isn't updated by the playground. I try to move my group where the sprite added to simmilar with the tilemap together. But it doesn't helps anymore. After the map movement my player staying on the right place but the playground thinks he has the old position couple of pixels behind them.
I have tryed everything but I couldn't solve this problem. Please help my Selim :)
Thank you in advance!
I have a position problem with my player sprite after the tilemap has scrolled. Here is my code: http://lortschi.de/games/bd/
The playground is smaller created as the tilemap. So I can move the tilemap in the opposing direction when the player reached at a certain point on the map. In this case is the 800px mark. In my code is this the scrollStage function at line 196.
The curios problem after the map movement is, that my player sprite position isn't updated by the playground. I try to move my group where the sprite added to simmilar with the tilemap together. But it doesn't helps anymore. After the map movement my player staying on the right place but the playground thinks he has the old position couple of pixels behind them.
I have tryed everything but I couldn't solve this problem. Please help my Selim :)
Thank you in advance!
Comments
Ok, anyway is this maybe a bug in the engin, that the added groups and sprites to playground won't be position-updated by tilemap moving?
I'm not sure exactly if I understand the problem you're describing but since the player is not a child of the tilemap it shouldn't move when you move the tilemap.
The structure of you DOM looks like this at the moment: if you want to make the player move along the tilemap you could make it a child of the tilemap: or put both of them in a group and move the group instead:
oh yes you're right! I created now a toplevel group "view" and put my tilemap and all the other groups in it. The same structure as you mentioned by your 3th example. Now I get everything scrolled. But sry there is a next problem :( After moving the tilemap the playground width wouldn't been calculated new and the end of the playground is somewhere in the middle of the tilemap. If you test the game you will it see. You can't move the player till the end of the area. How can I solve this problem after moving the tilemap?
Thank you for your help!
Thanks for all helps!
Sorry I didn't answered you earlier. The only problem I encountered in you game (that look, sound and play very well now) is that once the screen has been scrolled the player can't pass the place where the screen used to end.
This is due to the following error in your code:
At the last line I quoted you can see that you check that the player isn't farther away that the width of the screen where you should really check that she isn't farther away than the width of the level.
Hopes it solve you problem and don't hesitate to ask if you have more question, I will try to answer them faster !
By the way Selim, I have another question. Now is so that on the hidden tilemap areas the animations aren't active. That may couse me a problem in the next level of the game. There will be some anamies and they must act continuously in background.
Is there currently a possibility to activate the whole animations? Also in the not visible part of the tilemap?