Sign in to follow this  
hamdirizal

[ASK] Why My Collision Functions Are Not Called

Recommended Posts

Hi. All,

 

I have this script (use debugdraw to see the shape). When I use Panda 1.12.0 it is working properly. But when I switch to Panda 1.13.1 the collision functions are not called. Is this bug or something? Thanks.

game.module(    'game.main').body(function() {game.createScene('Main', {    init: function() {       this.world = new game.World(0, 100);	   	   var f=new game.Food();	   var m=new game.Monster();    }});game.createClass('Food', {	init: function() {		this.radius=9;		this.body = new game.Body({            position: { x: 320/2, y: 100 },            velocityLimit: { x: 300, y: 800 },            mass:1,            collisionGroup: 1,            collideAgainst: [0]        });        this.body.velocity.y=-100;        this.body.collide = this.collide.bind(this);        var shape=new game.Circle(this.radius);        this.body.addShape(shape);        game.scene.world.addBody(this.body);        game.scene.addObject(this);		console.log(this.body)	},//end Init()	collide:function(opponent){		console.log('Collision! On  food')	}});//End Class 'Food'game.createClass('Monster', {	init: function() {		this.radius=15;		this.body = new game.Body({            position: { x: 320/2, y: 300 },            velocityLimit: { x: 0, y: 0 },            collisionGroup: 0,			collideAgainst: [1]        });		        this.body.collide = this.collide.bind(this);        var shape=new game.Circle(this.radius);		var rshape=new game.Rectangle(40,40);        this.body.addShape(rshape);        game.scene.world.addBody(this.body);        game.scene.addObject(this);		console.log(this.body)	},//end Init()	collide:function(opponent){		console.log('Collision!')	}});//End Class 'Monster'});//End body

PS: Sorry for my english. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.