Apoptyzm

Members
  • Content Count

    6
  • Joined

  • Last visited

  1. So my gameplay works as intended, but menu buttons do not. Since my game starts with a menu i can't do anything at start. Before creating menu screen i stop the simulation with: GameController.prototype.pauseSimulation = function () { this.game.physics.arcade.isPaused=true; pause_simulation = true; this.game.time.events.stop(false);};Since Phaser ver. 2.something it doesn't stop input listeners. Then i have this "store" view that won't react: /* global debug, Sound, zsummary_text, Phaser *//** * Store Screen with upgrades and powerups to unlock * @param {type} Phaser_game * @param {type} Powerups_manager * @returns {UpgradesView} */function UpgradesView(Phaser_game, Powerups_manager) { this.game = Phaser_game; this.profile; this.upgrades= new Upgrades(this.game);;//UpgradesData this.PowerupsMng = Powerups_manager; this.sprites;//group this.icons;//group this.buyBtn; this.label; this.tint= { DEFAULT: 0xffffff, BLOCKED: 0xff0000, AVAILABLE: 0xffffff, UPGRADED: 0x0000ff }; this.highlightedupgradekey; this.INVALID=-1; this.reset(); };UpgradesView.prototype.reset = function (){ this.sprites = this.game.add.group(); this.icons = this.game.add.group(); this.upgrades.reset(); this.highlightedupgradekey=this.INVALID;; var style = { font: 'bold 16pt Arial', fill: 'white', align: 'left', wordWrap: true, wordWrapWidth: 450 }; this.label = this.game.add.text(200, 700, " ", style); this.label.fixedToCamera = (true); if(debug===true) console.log('UpgradesView reset'); //load profile data};UpgradesView.prototype.preload = function (){ this.upgrades.preload(); this.game.load.image("summary-background", 'img/summaryscreen/summary-background.jpg'); this.game.load.image("button-play", 'img/buttons/button-play.png '); if(debug===true) console.log('UpgradesView preload');};UpgradesView.prototype.create = function (){ this.upgrades.create(); if(debug===true) console.log('UpgradesView create');};UpgradesView.prototype.show = function (){ //this.summary.createSummary(); //TODO: potential leak this.reset(); this.upgrades.loadData(); //this.updateProfile(); this.createBackground(); this.createUpgradesGrid(); this.createPlayButton(); this.createMenuButton(); this.createBuyButton(); //this.background.reset(this.game.camera.x+400+WindowGameW*(0.5),this.game.camera.y +WindowGameH*(0.5),1); //this.background.visible=true; if(debug===true) console.log('UpgradesView show');};UpgradesView.prototype.hide = function (){ //this.background.visible=false; this.sprites.destroy(); this.icons.destroy(); this.label.destroy(); //this.background.destroy(); //this.play_again_btn.destroy(); //this.game.world.remove(this.play_again_btn);};UpgradesView.prototype.onPlayAgainBtn= function(){ if(debug===true) console.log('UpgradesView onPlayAgainBtn'); this.hide(); this.game.deadfish.gamecontroller.gotoStartGame(); Sound.playButtonPress();};UpgradesView.prototype.onMenuBtn= function(){ this.hide(); this.game.deadfish.gamecontroller.gotoStartGame(); Sound.playButtonPress(); if(debug===true) console.log('UpgradesView onPlayAgainBtn Click');};UpgradesView.prototype.updateProfile= function(){ //this.game.deadfish.player.getProfile().updateFromLevelData(this.summary.getSummary());};UpgradesView.prototype.getSummaryData= function(){ //return this.summary.getSummary();};UpgradesView.prototype.createPlayButton = function (){ //this.play_again_btn = game.add.text(this.game.camera.x+100,this.game.camera.y, 'Fafarafa', { font: '28px Arial', fill: '#f0f' }); this.play_again_btn = this.game.add.sprite(WindowGameW-200,WindowGameH-200, 'button-play'); this.play_again_btn.inputEnabled = true; this.play_again_btn.events.onInputUp.add(this.onPlayAgainBtn.bind(this)); this.play_again_btn.fixedToCamera = (true); this.play_again_btn.z=zsummary_text+1; this.sprites.add(this.play_again_btn);};UpgradesView.prototype.createMenuButton = function (){ //this.play_again_btn = game.add.text(this.game.camera.x+100,this.game.camera.y, 'Fafarafa', { font: '28px Arial', fill: '#f0f' }); var MenuButton = this.game.add.sprite(WindowGameW-200,WindowGameH-100, 'button-play'); MenuButton.inputEnabled = true; MenuButton.events.onInputUp.add(this.onMenuBtn.bind(this)); MenuButton.fixedToCamera = (true); MenuButton.z=zsummary_text+1; this.sprites.add(MenuButton);};UpgradesView.prototype.createBuyButton = function (){ //this.play_again_btn = game.add.text(this.game.camera.x+100,this.game.camera.y, 'Fafarafa', { font: '28px Arial', fill: '#f0f' }); this.buyBtn = this.game.add.sprite(50,800, 'button-play'); this.buyBtn.inputEnabled = true; this.buyBtn.events.onInputUp.add(this.onBuyBtnClick.bind(this)); this.buyBtn.fixedToCamera = (true); this.buyBtn.z=zsummary_text+1; this.sprites.add(this.buyBtn);};UpgradesView.prototype.createBackground = function (){ //this.background = game.add.sprite(this.game.camera.x+WindowGameW*(0.5),this.game.camera.y+WindowGameH*0.0, 'summary-background'); //this.background = game.add.sprite(this.game.camera.x,this.game.camera.y, 'summary-background'); this.background = this.game.add.sprite(WindowGameW*(0.5),WindowGameH*0.5, 'summary-background'); var ratio = WindowGameW / this.background.width; this.background.scale.x=ratio; this.background.scale.y=ratio; this.background.alpha=1; this.background.anchor.set(0.5); this.background.inputEnabled = false; this.background.z=zsummary_screen; this.background.fixedToCamera = (true); //this.background.tint = 0xcccccc; this.sprites.add(this.background);};UpgradesView.prototype.createUpgradesGrid = function (){ var upperx=10; var uppery=100; var rows=2; var columns =6; var stepx=WindowGameW/columns; var stepy=80; var profile =this.game.deadfish.player.getProfile(); var spr; var key=0;//index // for (var y=0; y< rows; y++){ for(var x=0;x<columns;x++){ //sprite spr = game.add.sprite(upperx + stepx*x,uppery + stepy*y, this.upgrades.assets[key]); spr.inputEnabled = true; spr.z=zsummary_text; spr.name = this.upgrades.assets[key]; spr.key = key; spr.fixedToCamera = (true); spr.events.onInputUp.add(this.onUpgradeClick.bind(this)); //set color status if(this.upgrades.isUpgraded(key)) spr.tint = this.tint.UPGRADED; else if(this.upgrades.getUpgradeCost(key) > profile.getMoney() ) spr.tint = this.tint.BLOCKED; else spr.tint = this.tint.AVAILABLE; key++; this.icons.add(spr); } } //powerups key=0; uppery = uppery + stepy*(rows+1); var offset = this.upgrades.getKeysLen(); for (var y=0; y< rows; y++){ for(var x=0;x<columns;x++){ //sprite //jebany hack, żeby się dało iterować liste indexem numerowym.. var becausejskey ; var i=0; for(var t in this.PowerupsMng.KEYS){ if(i===key){ becausejskey = t; break; } i++; } //var is=this.game.cache.checkImageKey(this.PowerupsMng.KEYS[becausejskey] ); //is=this.game.cache.checkImageKey("points_multi.png" ); spr = game.add.sprite(upperx + stepx*x,uppery + stepy*y, this.PowerupsMng.KEYS[becausejskey]); spr.inputEnabled = true; spr.z=zsummary_text; spr.scale.setTo(2); spr.name = this.PowerupsMng.KEYS[becausejskey]; spr.key = offset+key; spr.fixedToCamera = (true); spr.events.onInputUp.add(this.onUpgradeClick.bind(this)); //set color status if(this.upgrades.isUpgraded(spr.key)) spr.tint = this.tint.UPGRADED; else if(this.upgrades.getUpgradeCost(spr.key) > profile.getMoney() ) spr.tint = this.tint.BLOCKED; else spr.tint = this.tint.AVAILABLE; key++; this.icons.add(spr); } } };UpgradesView.prototype.onBuyBtnClick = function (spr, pointer){ if(this.highlightedupgradekey===this.INVALID) alert("onBuyButton error"); if(this.upgrades.isUpgraded(this.highlightedupgradekey)) return; else if(this.upgrades.getUpgradeCost(this.highlightedupgradekey) > this.game.deadfish.player.getProfile().getMoney() ) return; this.upgrades.upgrade(this.highlightedupgradekey); //this.upgrades.applyUpgrade(this.highlightedupgradekey); this.updateAllTints(); this.updateBuyBtnTint(spr); this.updateLabel(spr); //snd Sound.playBuyItem(); if(debug===true) console.log('UpgradesView onBuyBtnClick');};//when someone clicks upgrade iconUpgradesView.prototype.onUpgradeClick = function (spr, pointer){ var icon; if(this.highlightedupgradekey !==this.INVALID){ icon = this.icons.getAt(this.highlightedupgradekey); icon.scale= this.lasthighlightedscale; } this.highlightedupgradekey = spr.key; icon =this.icons.getAt(spr.key); this.lasthighlightedscale = icon.scale; icon.scale = new Phaser.Point(icon.scale.x*1.5,icon.scale.y*1.5); this.updateLabel(spr); this.updateBuyBtnTint(spr);};UpgradesView.prototype.updateTint = function (spr){ if(this.upgrades.isUpgraded(spr.key)) spr.tint = this.tint.UPGRADED; else if(this.upgrades.getUpgradeCost(spr.key) > this.game.deadfish.player.getProfile().getMoney() ) spr.tint = this.tint.BLOCKED; else spr.tint = this.tint.AVAILABLE;};UpgradesView.prototype.updateBuyBtnTint = function (spr){ if(this.upgrades.isUpgraded(spr.key)) this.buyBtn.tint = this.tint.UPGRADED; else if(this.upgrades.getUpgradeCost(spr.key) > this.game.deadfish.player.getProfile().getMoney() ) this.buyBtn.tint = this.tint.BLOCKED; else this.buyBtn.tint = this.tint.AVAILABLE;};UpgradesView.prototype.updateAllTints = function (){ this.icons.forEach( this.updateTint ,this);};UpgradesView.prototype.updateLabel = function (sprite){ var money = this.game.deadfish.player.getProfile().getMoney(); this.label.setText( this.upgrades.labels[sprite.key] + "\n\nmoney: "+money);};
  2. I have to say that moving from 2.3 to 2.4.1 solved some of my issues with performance on low fps, and i love it, but somehow on phone nothing works. On Chrome i get my first screen and input doesn't work, and on stock browser(and-4.0.4) i get blank screen. Everything works on PC. I get no errors in mobile Chrome js console. Did i miss something in release notes?
  3. Hi, somehow i can't use my group as a layer (example: http://examples.phaser.io/_site/view_full.html?d=groups&f=group+as+layer.js&t=group%20as%20layer ). Whenever i add a sprite to a group, it's z layer is changed by group to match sprite's index number in group. Basicly this code : GroupWithTemplate.prototype.createObject = function(){ if(this.GroupSize < this.MaximumObjAmount){ var obj = this.Builder.construct(this.object_original.objecttype); LOGADD("GroupWithTemplate.prototype.createObject fresh z: "+obj.z); LOGADD("this.group.z: "+this.group.z); this.group.add(obj ); this.GroupSize++; LOGADD("GroupWithTemplate.prototype.createObject ingroup z: "+obj.z); }};produces output like this: GroupWithTemplate.prototype.createObject fresh z: 12debug.js:18 this.group.z: 12debug.js:18 GroupWithTemplate.prototype.createObject ingroup z: 1debug.js:18 GroupWithTemplate.prototype.createObject fresh z: 12debug.js:18 this.group.z: 12debug.js:18 GroupWithTemplate.prototype.createObject ingroup z: 2debug.js:18 GroupWithTemplate.prototype.createObject fresh z: 12debug.js:18 this.group.z: 12debug.js:18 GroupWithTemplate.prototype.createObject ingroup z: 3debug.js:18 GroupWithTemplate.prototype.createObject fresh z: 12debug.js:18 this.group.z: 12debug.js:18 GroupWithTemplate.prototype.createObject ingroup z: 4debug.js:18 GroupWithTemplate.prototype.createObject fresh z: 12debug.js:18 this.group.z: 12debug.js:18 GroupWithTemplate.prototype.createObject ingroup z: 5debug.js:18 GroupWithTemplate.prototype.createObject fresh z: 12debug.js:18 this.group.z: 12debug.js:18 GroupWithTemplate.prototype.createObject ingroup z: 6debug.js:18 GroupWithTemplate.prototype.createObject fresh z: 12debug.js:18 this.group.z: 12debug.js:18 GroupWithTemplate.prototype.createObject ingroup z: 7I checked group sourcecode, and the method responsible is updateZ() but its called in places that i never use, like sort() or remove(). I would apreciate any sugestions.
  4. Hi, i have basic timed event that won't call provided method, not even once... It's so basic that i don't know what can be the cause. EnemiesManager.prototype.singleEnemySpawnUpdate = function () { if(this.timer.events.length===0){ this.timer.add( Phaser.Timer.SECOND * this.game.rnd.integerInRange(1,2), this.addRandomEnemy, this); this.timer.start(0); }};//never called methodEnemiesManager.prototype.addRandomEnemy = function(){ this.getRandomGroup().addObject(this.game.rnd.integerInRange(100,700),this.game.camera.y+100); this.timer.stop(true);};
  5. yes that was it, i wasted all saturday because of ().
  6. Hi, i can't get group.forEach methods to work. Everytime i call them, callback method receives only one null. I tried it on different groups in different parts of the code(just after reset/revive) without any luck. Player.prototype.onClick03 = function () { FloorBuilder.group.forEachExists(this.onClick03Callback(), this); };Player.prototype.onClick03Callback = function (floor) { console.log("tick");//gets called only once if (floor == null) { console.log("onClick03Callback error no floor"); return false;//always ends here once }}My groups always have atleast 10 alive sprites, that i can see in game. This is my little example: function testmethod() { game.load.image("empty", 'img/fish.png'); var physengine = game.physics.arcade; var group = game.add.group(); //create for (var i = 0; i < 5; i++) { var c = group.create(i, //x i * 2, //y 'empty'//floor name random ); //console.log('adding: '+ c.key); c.name = 'testfloor'; physengine.enable(c); c.body.allowGravity = false; c.body.immovable = true; c.body.checkCollision.left = false; c.body.checkCollision.right = false; c.body.checkCollision.down = false; c.kill(); if (c.exists) { console.log("bug"); } } //add to game for (var i = 0; i<5; i++) { console.log("t"); var c = group.getFirstDead(); c.reset(i * c.width, 300 - c.height); c.body.immovable = true; c.body.checkCollision.left = false; c.body.checkCollision.right = false; c.body.checkCollision.down = false; }//works until this line group.forEachExists(player.onClick03Callback(), null);//group.forEachAlive(player.onClick03Callback(), null);}Player.prototype.onClick03Callback = function (floor) { console.log("floor check tick");// :< if (floor == null) { console.log("onClick03Callback error no floor"); return false; }}What am i doing wrong?