Ghonsha Posted July 26, 2015 Share Posted July 26, 2015 Hello, I am new in this community, my name is Gonzalo. I started this weekend to develop with Phaser, I dont have experience in game development but i decided to start with this framework.. I did the tutorial without problems, and all worked as expected, but now im writing my own code and i have some issues. I loaded two spritesheet, a player and a flag and i want to set a collision handler with a callback function between them. But it doesn't work as expected, and the callback is never called. I followed the basic project template, and here is the code of the Game.js which i think that is important: BasicGame.Game.prototype = { create: function () { this.physics.startSystem(Phaser.Physics.ARCADE); this.flag = this.add.sprite(this.world.centerX, this.world.centerY, "flag"); this.flag.animations.add('vuela', [4, 5, 6, 7], 10, true); this.physics.enable(this.flag, Phaser.Physics.ARCADE); this.player.sprite = this.add.sprite(0, this.world.height, 'dude'); this.player.flag = false; this.physics.enable(this.player.sprite, Phaser.Physics.ARCADE); this.player.sprite.body.bounce.y = 0.0; this.player.sprite.body.gravity.y = 1; this.player.sprite.body.collideWorldBounds = true; // Our controls. this.cursors = this.input.keyboard.createCursorKeys(); }, update: function () { this.physics.arcade.collide(this.player.spite, this.flag, this.takeFlag, null, this); // apply velocity over player's body }, takeFlag: function(player, flag) { alert("flag"); this.player.flag = true; this.flag.kill(); },}; I also attached the entire project, in case that the code that i showed it isn't enough. Thanks in advance guys!! PS: i recomment run the project on Chrome, because on Firefox im having problems with this issue too: https://github.com/photonstorm/phaser/issues/1932 PS2: Sorry for my english, it isn't my native lenguage. first.zip Link to comment Share on other sites More sharing options...
rich Posted July 26, 2015 Share Posted July 26, 2015 this.physics.arcade.collide(this.player.spite, this.flag, this.takeFlag, null, this);Shouldn't that be this.player.sprite ? Link to comment Share on other sites More sharing options...
Tilde Posted July 27, 2015 Share Posted July 27, 2015 Note to self: Add spite property to entities. By the way, this should throw an error. Make sure you're checking a console to see if javascript errors come up! Link to comment Share on other sites More sharing options...
Ghonsha Posted July 27, 2015 Author Share Posted July 27, 2015 Woo that was the problem, i spent hours on that and i couldn't see it. Sory, for spend your time! Note to self: Add spite property to entities. By the way, this should throw an error. Make sure you're checking a console to see if javascript errors come up! I checked the console but no error was shown. Link to comment Share on other sites More sharing options...
Tilde Posted July 27, 2015 Share Posted July 27, 2015 Huh, in my console, trying to pass a property that doesn't exist would throw an error. And this was on Chrome? Link to comment Share on other sites More sharing options...
Ghonsha Posted July 27, 2015 Author Share Posted July 27, 2015 I tried this on Firefox and Chromium, because im on Ubuntu. Tilde 1 Link to comment Share on other sites More sharing options...
Tilde Posted July 27, 2015 Share Posted July 27, 2015 I see, interesting! Thanks for the info, it may come in handy later. Link to comment Share on other sites More sharing options...
Recommended Posts