• Content count

  • Joined

  • Last visited

  1. Spawn an image when clicking a button

    Once again, thank you!
  2. I keep getting this.add is undefined. // Building button ui1.on('pointerdown', function () { var window = this.add.image(0, 0, 'window').setOrigin(0); window.setScrollFactor(0); window.setDepth(1002); window.x = 20; window.y = 20; }); I'm trying to spawn an image into the game when the user clicks on the button.
  3. Reference dynamic sprite

    This example worked. Thank you.
  4. Reference dynamic sprite

    Sorry, last time I coded is when I was working with AS2, and I'm picking this up slowly. var sprite = this.add.sprite(pointer.x + cam.scrollX, pointer.y + cam.scrollY, 'small_fence').setInteractive(); sprite.iName = fenceCount; sprite.on('pointerdown', function () { this.destroy(); }) I spawn sprites in and make them interactive. What I'm trying to do is, I want to reference these sprites later. How can I reference a specific sprite? For example in AS2, I used to be able to give them an instance name like "Sprite1." I would then be able to reference it later like: _root.Sprite1 Is there a way to do this with Phaser, so I can manipulate the sprite when I can't use this.
  5. Reference dynamic sprite

    When the user clicks on the screen, it spawns in a sprite. I'm trying to reference these sprites later, how can I do that? For example: = "Example"; Sprite1.destroy(); = "Example"; Sprite2.destroy();