1 decade ago by jtokarchuk
so I found this code in the forums, which is immensely helpful.
issue is -- the player is shifted to the right. I know what it is, it's not taking into account the player's width/2 (which in this case would be 8)
just not quite sure hwo to implement it properly without seeing black overscroll on the edges.
scrollScreen: function() {
if(this.player.pos.x > (ig.game.collisionMap.width*ig.game.collisionMap.tilesize-ig.system.width/2))
{
this.screen.x = ig.game.collisionMap.width*ig.game.collisionMap.tilesize-ig.system.width;
}
else if (this.player.pos.x < ig.system.width/2)
{
this.screen.x = 0;
}
else
{
this.screen.x = (this.player.pos.x - ig.system.width/2);
}
if(this.player.pos.y > (ig.game.collisionMap.height*ig.game.collisionMap.tilesize-ig.system.height/2))
{
this.screen.y = ig.game.collisionMap.height*ig.game.collisionMap.tilesize-ig.system.height;
}
else if (this.player.pos.y < ig.system.height/2)
{
this.screen.y = 0;
}
else
{
this.screen.y = (this.player.pos.y - ig.system.height/2);
}
}
issue is -- the player is shifted to the right. I know what it is, it's not taking into account the player's width/2 (which in this case would be 8)
just not quite sure hwo to implement it properly without seeing black overscroll on the edges.
