Jump to content

Search the Community

Showing results for tags 'bitmapData mobile performance'.

  • 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 1 result

  1. Hello all, I am new to Phaser and after some tutorials, I was trying this bit of code: <script> DemoState = function () { }; DemoState.prototype.create = function () { this.p1 = new Phaser.Point(-1, -1); this.p2 = new Phaser.Point(0, 0); this.input.mouse.capture = true; if (game.device.desktop) { this.input.activePointer.leftButton.onUp.add(this.addLine, this); } else { this.input.onUp.add(this.addLine, this); } this.bmdRuler = this.add.bitmapData(430, 250); this.rulerSprite = this.add.sprite(0, 0, this.bmdRuler); this.bmdRuler.ctx.lineWidth = "20"; this.bmdRuler.ctx.strokeStyle = "#00ffff"; this.bmdRuler.ctx.lineCap = 'round'; this.bmdMarker = this.make.bitmapData(430, 250); this.add.sprite(0, 0, this.bmdMarker); this.bmdMarker.ctx.lineWidth = "20"; this.bmdMarker.ctx.strokeStyle = "rgba(200, 100, 100, 1)"; this.bmdMarker.ctx.lineCap = 'round'; }; DemoState.prototype.addLine = function () { this.bmdRuler.clear(); this.bmdMarker.ctx.beginPath(); this.bmdMarker.ctx.moveTo(this.p1.x, this.p1.y); this.bmdMarker.ctx.lineTo(this.p2.x, this.p2.y); this.bmdMarker.ctx.stroke(); this.bmdMarker.dirty = true; this.p1.set(-1, -1); }; DemoState.prototype.rulerLine = function () { this.world.bringToTop(this.rulerSprite); this.bmdRuler.clear(); this.bmdRuler.ctx.beginPath(); this.bmdRuler.ctx.moveTo(this.p1.x, this.p1.y); this.bmdRuler.ctx.lineTo(this.p2.x, this.p2.y); this.bmdRuler.ctx.stroke(); }; DemoState.prototype.update = function () { if (this.input.activePointer.leftButton.isDown || this.input.activePointer.isDown) { if (this.p1.x == -1 && this.p1.y == -1) this.p1.set(this.input.activePointer.position.x, this.input.activePointer.position.y); this.p2.set(this.input.activePointer.position.x, this.input.activePointer.position.y); this.rulerLine(); } }; var game = new Phaser.Game(430, 250, Phaser.AUTO, ''); game.state.add('demo', DemoState); game.state.start('demo'); </script> It runs ok on desktops but on mobile phones after you hve drawn a few lines it hangs. (I have noticed that on desktops it casues the browser to use up large amounts of ram. What am I doing wrong? How can I improve on this so that it will not hang up mobile browsers? Thanks in advance for any help. Jesús.
×
×
  • Create New...