Jump to content

Search the Community

Showing results for tags 'runtime phaser create sprite'.

  • 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. Hi Guys, I have a problem. I am calling a function by clicking the mouse button, which creates a new sprite in theory. 'use strict';var Stones = function(game, x, y, frame) { this.stones = Phaser.Sprite.call(this, game, x, y, 'stones', frame); this.anchor.setTo(0.5,0.5); // initialize your prefab here //this.stones.scale.setTo(0.5, 0.5);};Stones.prototype = Object.create(Phaser.Sprite.prototype);Stones.prototype.constructor = Stones;Stones.prototype.update = function() { // write your prefab's specific update code here };module.exports = Stones; 'use strict'; var Stoned = require('../prefabs/stones'); // 420 var count = 0; var stoneGroup; function Play() {} Play.prototype = { create: function() { this.game.physics.startSystem(Phaser.Physics.ARCADE); this.board = this.game.add.sprite(this.game.width/2-250, this.game.height/2-250, 'GoBoard'); //this.sprite.inputEnabled = true; this.game.physics.arcade.enable(this.board); this.game.stage.backgroundColor = '#DDDDDD'; var stones = new Stoned(this.game, 300, 300, 0); this.game.add.existing(stones); stones.scale.setTo(0.15,0.15); this.input.onDown.add(this.placeNextStone, {group: stoneGroup, input: this.input}, this); }, update: function() { }, placeNextStone: function(group, input) { var stones = new Stoned(this.game, 123, 123, 'stones'); this.game.add.existing(stones); /*console.log("test"); console.log(this.group); count++; console.log(this.input.x);*/ } }; module.exports = Play;The problem is this line " var stones = new Stoned(this.game, 123, 123, 'stones'); this.game.add.existing(stones);" in the placeNextStone function. It creates an error: Uncaught TypeError: Cannot read property 'cache' of [email protected]:49150 Phaser.Component.Core.init @ phaser.js:47756 Phaser.Sprite @ phaser.js:50869 Stones @ game.js:22 Play.placeNextStone @ game.js:154 Phaser.SignalBinding.execute @ phaser.js:31642 Phaser.Signal.dispatch @ phaser.js:31447 Phaser.Pointer.start @ phaser.js:42440 Phaser.Mouse.onMouseDown @ phaser.js:40679 _onMouseDown @ phaser.js:40595
×
×
  • Create New...