Sign in to follow this  
goide

Problem with Class Graphic and the Rectangle class (Panda 2.0)

Recommended Posts

Not if the following is an error.
 
I'm learning this empirically Panda 2.0 game engine, I'm practicing what they learned. and at the moment I am working with graphics.
 
So I'm developing a mini platform game for so implement everything learned. I do not have as sprites, then my hero will be a rectangle.
 
The next thing is that in my class hero who I have called "Cat", I created the body of my hero, the rectangle will be red in the graphic class, adding a rectangle to this rectangle so add to the body of the hero , and finally adding it to the world as we will see in the code.
 
game.createClass('Gato',{        init: function(x,y){            this.cuerpo = new game.Body();            this.cuerpo.collisionGroup = 1;            this.cuerpo.collideAgainst = [0];            this.cuerpo.position.set(x,y);            this.cuerpo.collide = this.colisiones.bind(this);                        //Class Graphics            this.catGrap = new game.Graphics();            this.catGrap.anchorCenter();            this.catGrap.fillColor = '#f00';            this.catGrap.drawRect(this.cuerpo.position.x,this.cuerpo.position.y,50,50);            this.catGrap.addTo(game.scene.stage);                        //Rectangle(50,50)            var catShape = new game.Rectangle(this.catGrap.width, this.catGrap.height); //change                        this.cuerpo.addShape(catShape);            this.cuerpo.addTo(game.scene.world);                    },                colisiones: function(colision){            if(colision.collisionGroup === 0){                this.cuerpo.velocity.y *= -.5; //Work            }            return true;        },                update: function(){            this.catGrap.position.copy(this.cuerpo.position);         }    });
The problem is this, the width and height of my body will be 50.
 
and when I run the code, it is as follows.
 
Captura%20de%20pantalla%20de%202015-06-3
 
so that we can give a wide and long rectangle that resembles the hero, I have to double the value of the rectangle that will add to the body, or it has to value 100, and is as follows.
 
 var catShape = new game.Rectangle(100, 100);
 
Captura%20de%20pantalla%20de%202015-06-3
 
My question is, and look at the documentation, and I know, as equip the red rectangle is even with the box body. since it is not working properly.
 
and as seen in the last image, the high is unbalanced.
 
Thanks.
 
 

 

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.