Jump to content

Search the Community

Showing results for tags 'destroy()'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 3 results

  1. Hi there. I'm not shure, that I've correctly understood the way Object.destroy() works. I have a language selection state at the begining of my project. This is a scene that contains two buttons and text label. Also, as every scene in project, it contains a simple loader. index.htm <!doctype html> <html> <head> <meta charset="UTF-8" /> <title></title> <script type="text/javascript" src="src/phaser.min.js"></script> <script type='text/javascript' src='src/langSelect.js'></script> <script type='text/javascript' src='src/mainMenu.js'></script> <script type='text/javascript' src='src/Credits.js'></script> <script type="text/javascript" src="src/scene1.js"></script> <style type="text/css"> body { margin: 0; } </style> </head> <body> <script type='text/javascript'> //width and height of the game var width=848; var height=480; window.onload=function(){ var game = new Phaser.Game(width, height, Phaser.AUTO, 'game'); game.state.add('langSelect',langSelect); game.state.add('mainMenu',mainMenu); game.state.add('Credits',Credits); game.state.add('Scene1',Scene1); game.state.start('langSelect'); }; </script> </body></html>langSelect.js var langSelect=function(game){ var btnEng; var btnRus; var loadText; var langText; var pressed=false; var loaded=false;};langSelect.prototype={ preload: function(){}, create: function(){ this.load.onFileComplete.add(this.fileComplete,this); this.load.onLoadComplete.add(this.loadComplete,this); this.loadText=this.add.text(50,this.game.world.height/2,'Loading...',{fill:'#FFFFFF'}); this.start(); }, start: function(){ this.game.load.image('btnEng','../pics/interface/english.png'); this.game.load.image('btnRus','../pics/interface/russian.png'); this.game.load.start(); }, fileComplete: function(progress,cacheKey,success,totalLoaded,totalFiles){ this.loadText.setText('File complete: '+progress+'% - '+totalLoaded+' out of '+totalFiles); }, loadComplete: function(){ var self=this; this.langText=this.add.text(50,this.game.world.height/2.5,'Please select your language:',{fill: '#ffa800'}); this.btnEng=this.game.add.button(0,this.game.world.height/2,'btnEng',function(){ localStorage.setItem('lang','eng'); self.pressed=true; },null,0,0,0); this.btnRus=this.game.add.button(0,this.game.world.height/2,'btnRus',function(){ localStorage.setItem('lang','rus'); self.pressed=true; },null,0,0,0); this.btnEng.x=this.game.world.width/2-this.btnEng.width; this.btnRus.x=this.game.world.width/2+this.btnRus.width; this.loaded=true; }, update: function(){ if (this.loaded){ this.loadText.destroy(); }; if (this.pressed){ this.pressed=false; this.loaded=false; this.game.state.start('mainMenu'); } }};When I click any button, I'm getting that error: Uncaught TypeError: Cannot set property 'font' of nullb.Text.updateText @ phaser.min.js:10b.Text.updateTransform @ phaser.min.js:3Object.defineProperty.set @ phaser.min.js:10b.Text.setText @ phaser.min.js:3langSelect.fileComplete @ langSelect.js:23b.SignalBinding.execute @ phaser.min.js:6b.Signal.dispatch @ phaser.min.js:6dispatch @ phaser.min.js:6b.Loader.nextFile @ phaser.min.js:13b.Loader.fileComplete @ phaser.min.js:13a.data.onload @ phaser.min.js:1323 line of langSelect.js is: this.loadText.setText('File complete: '+progress+'% - '+totalLoaded+' out of '+totalFiles);But this text object destroyed right after scene load. Please tell me what I'm doing wrong. Thanks
  2. Hi I am currently writing a game, but I have noticed that it is pushing the processor to the max. Previous discussions would suggest that it can be a problem with the browser, however I think I have too much going on at the same time. I have created a version of Asteroids, so as you can imagine there a lot of collisions, which from my understanding can cause the processor to work hard. My question is, I am currently using Destroy() when the asteroids are hit, would I be better off using Kill() instead? What would also be the most efficient way to recycle the asteroids? collisionHandler: function (bullet, asteroid) { //get asteroid.kill type and position var asteroidKey = asteroid.key.toString(); var asteroidX = asteroid.position.x; var asteroidY = asteroid.position.y; // When a bullet hits an asteroid we kill them both bullet.kill(); asteroid.destroy(); ... The game can be played at http://tjs_uk.bitbucket.org I intend to reduce the amount of code, now that it is working (and I have a better understanding of the Phaser... sort of??) Thanks in advance. Trev.
  3. I got this setup: update: function() { this.balls.forEach(this.ballUpdate, this);}ballUpdate: function(ball) {if (ball.body.y > this.game.world.height + ball.height) {ball.destroy();}}Which results in: Uncaught TypeError: Cannot read property 'alive' of null Game.js:566 BasicGame.Game.ballUpdateGame.js:566 Phaser.Group.forEachphaser.js:12324 BasicGame.Game.updateGame.js:173 Phaser.StateManager.updatephaser.js:10138 Phaser.Game.updatephaser.js:13701 Phaser.RequestAnimationFrame.updateRAFphaser.js:22114 _onLoopphaser.js:22099 I tried: update: function() { if(this.balls.countLiving() > 0) { this.balls.forEach(this.ballUpdate, this); }}
×
×
  • Create New...