1 decade ago by GHETTOCHiLD
all-
i am trying to lock my camera so that it only shows my map and not the outside bounds. currently when i start the game i see the end of the map plus dead space (black space). i want to lock the camera so that when i start the game i only see the end of my map and as i move to the top of it i stop when i hit the end of the map and do not see any black screen. i am currently doing the following in my update function in main.js
any help would be appreciated.
i am trying to lock my camera so that it only shows my map and not the outside bounds. currently when i start the game i see the end of the map plus dead space (black space). i want to lock the camera so that when i start the game i only see the end of my map and as i move to the top of it i stop when i hit the end of the map and do not see any black screen. i am currently doing the following in my update function in main.js
any help would be appreciated.
MCommute = ig.Game.extend({
font: new ig.Font( 'media/04b03.font.png' ),
camera: null,
init: function() {
// Initialize your game here; bind keys etc.
// bind keys
ig.input.bind(ig.KEY.A, 'left');
ig.input.bind(ig.KEY.D, 'right');
ig.input.bind(ig.KEY.W, 'gas');
ig.input.bind(ig.KEY.S, 'break');
camera = this.getEntitiesByType(EntityPlayer)[0];
ig.game.screen.y = 2500;
ig.game.screen.x = 0;
// load level
this.loadLevel(LevelLevel1);
},
update: function() {
this.parent();
//move the camera with the player
if(camera){
this.screen.x = camera.pos.x - ig.system.width/2;
this.screen.y = camera.pos.y - ig.system.height/2;
}
},
