julien74370 Posted July 27, 2015 Share Posted July 27, 2015 Hi everyone, In first excuse me for my level in english I need some advices to do a game. I have in my game a group wich represents my background scenery. It contains one background sprite and some items sprite. However i want to set offset on my group depending on the size of the screen. Backgroud Sprite size : 1650px * 1050px Example : Black : facultative content visible (1620 * 1050)White : obligatory content visible (980*520)Red: some items I did a class extending Phaser.Group and controller for switch group displayedfunction CameraPrefab(game, parent, name, addToStage, background, items) { // The super call to Phaser.Group Phaser.Group.call(this, game, parent, name, addToStage); var _this = this; // Add background to group this.create(0, 0, background); var item; // Add items to group items.forEach(function (item) { item = _this.create(parseInt(item.pos.x), parseInt(item.pos.y), "itm" + item.id + "_bgn" + item.pos.bgn + "_cam" + item.pos.cam); item.name = "item"; });}CameraPrefab.prototype = Object.create(Phaser.Group.prototype);CameraPrefab.prototype.constructor = CameraPrefab;function CameraController(scenery_info, position, game){ var _this = this; this.cams = {}; this.cam_position = 0; this.backgrouds_list = scenery_info.backgrounds; this.items_list = scenery_info.items; this.backgrouds_list.forEach(function(cam){ var backgroundToSet = 'cam_' + cam.id; _this.cams[cam.id] = new CameraPrefab(game, null, "camera", true, backgroundToSet, _this.getItemsByCamId(cam.id)) }); this.switchCamera(position);}I would like my game fit the screen size and if my screen size is smaller than 1650 * 1050 set offset until 980 * 520 I really looking for a way but i did not find one. Do you have an idea to do that? Thank you Link to comment Share on other sites More sharing options...
Recommended Posts