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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.