Jump to content

Search the Community

Showing results for tags 'getChildAt'.

  • 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. Hey Guys, I'm using typescript in visual studio for web and can't access the sprite methods when using though group call getChildAt() e.g this.objectsGroup.getChildAt(i).destroy(); This is the error I get Error 1 Build: Property 'destroy' does not exist on type 'DisplayObject'. Not sure if i'm meant to cast this? Any help would be much appreciated class below. module Test { export class Level1 extends Phaser.State { background: Phaser.Sprite; crossHairGroup: Phaser.Group; poleGroup: Phaser.Group; objectsGroup: Phaser.Group; crossHair: CrossHair; pole: Phaser.Sprite; object: Phaser.Sprite; create() { this.crossHairGroup = this.game.add.group(); this.poleGroup = this.game.add.group(); this.objectsGroup = this.game.add.group(); this.background = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, 'background'); this.background.anchor.setTo(0.5, 0.5); this.crossHair = new CrossHair(this.game, this.game.input.x, this.game.input.y, this.crossHairGroup); this.initializeObjects(); this.game.input.onDown.add(this.fire, this); } fire() { var bullet = this.crossHair.fire(); /* Check if bullet hits object */ for (var i = 0; i < this.objectsGroup.length; i++) { if (this.checkOverlap(this.objectsGroup.getChildAt(i), bullet)) { this.objectsGroup.add(this.object); /* this line not working */ //this.objectsGroup.getChildAt(i).destroy(); } } } checkOverlap(spriteA, spriteB) { var boundsA = spriteA.getBounds(); var boundsB = spriteB.getBounds(); return Phaser.Rectangle.intersects(boundsA, boundsB); } initializeObjects() { /* Initialize poles and objects */ for (var i = 0; i < 7; i++) { /* Top poles */ this.pole = new Pole(this.game,(i * -200), 235, false); this.poleGroup.add(this.pole); /* Bottom poles */ this.pole = new Pole(this.game,((i * 200) + 1024), 45, true); this.poleGroup.add(this.pole); /* Top objects */ this.object = new Object(this.game,(i * -200), 300, false); this.objectsGroup.add(this.object); /* Bottom objects */ this.object = new Object(this.game,((i * 200) + 1024), 100, true); this.objectsGroup.add(this.object); } } } }
×
×
  • Create New...