Jump to content

nak3ddogs
 Share

Recommended Posts

helo. pls someone help me. 

 

i wanna place a bg to my screen with auto scrilling infinitely. 

i tryed this code
 

          game.bg = this.game.add.tileSprite(0,0,800,480,'background');
          game.bg.autoScroll(-100,0);
 
and it looks like fine for the first 800 pixel but not inifinite for the whole game
after i tried to add this code for this
 
     game.bg.fixedToCamera = true;
 
and now i have the bg for the whole game and it is autoscrolling but when i move with my hero 
the bg  scrolling is not scrolling well relatively to my vision.
 
sry for my terrible english and thx for any advice!
Link to comment
Share on other sites

You probably want to manually scroll the tile in this case, so still use a tileSprite but in an update() function do this:

  game.bg.tilePosition.x = yourGameWorld.x ;  game.bg.tilePosition.y = yourGameWorld.y ;

where "yourGameWorld" is whatever you are using as a frame of reference. 

 

I'm don't think "fixedToCamera" is needed.  I'm assuming your character never moves on the screen, but the background does. If that's the case then the camera isn't moving. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...