Search the Community
Showing results for tags 'starstruck'.
-
i'm trying to follow the starstruck example in remake it in typescript and im getting an error i dont understand. This is what i have so far : create() { this.game.physics.startSystem(Phaser.Physics.ARCADE); this.game.stage.backgroundColor = '#000000'; this.bg = this.game.add.tileSprite(0, 0, 800, 600, 'background'); this.bg.fixedToCamera = true; this.map = this.game.add.tilemap('level1'); this.map.addTilesetImage('tiles-1'); this.map.setCollisionByExclusion([13, 14, 15, 16, 46, 47, 48, 49, 50, 51]); this.layer = this.map.createLayer('Tile Layer 1'); this.layer.resizeWorld(); this.game.physics.arcade.gravity.y = 250; this.player = this.game.add.sprite(32, 32, 'dude'); this.game.physics.enable(this.player, Phaser.Physics.ARCADE); this.player.body.bounc.y = 0.2; this.player.body.collideWorldBounds = true; this.player.body.setSize(20, 32, 5, 16); this.player.animations.add('left', [0, 1, 2, 3], 10, true); this.player.animations.add('turn', [4], 20, true); this.player.animations.add('right', [5, 6, 7, 8], 10, true); this.game.camera.follow(this.player); this.cursors = this.game.input.keyboard.createCursorKeys(); this.jumpbutton = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); } update() { this.game.physics.arcade.collide(this.player, this.layer); this.player.body.velocity.x = 0; if (this.cursors.right.isDown) { this.player.body.velocity.x = 150; this.player.animations.play('right'); } }everythings been loaded correctly in the preload method and im getting the error: Phaser v2.0.5 - Canvas - WebAudio http://phaser.io ♥♥♥ phaser.js:19908Uncaught TypeError: Cannot set property 'y' of undefined Main.ts:39Uncaught TypeError: Cannot read property 'right' of undefined Main.ts:58 the first error occurs in this area: this.game.physics.enable(this.player, Phaser.Physics.ARCADE); this.player.body.bounc.y = 0.2;the second here: this.player.body.velocity.x = 0; if (this.cursors.right.isDown) {what's happening?