android - andengine setposition of animatedsprite -


with andengine i'm trying create footbal game, when ball go in goal , dissapears screen, update score , reposition ball @ center of screen. update score in working well, not reposition. here code ball:

    final animatedsprite ball;     final body bodyball;     ball = new animatedsprite(centerx, centery,this.mballtextureregion, this.getvertexbufferobjectmanager());     bodyball = physicsfactory.createboxbody(this.mphysicsworld, ball, bodytype.dynamicbody, fixture_def);     ball.setuserdata(bodyball);     ball.animate(200);     this.mscene.registertoucharea(ball);     this.mscene.attachchild(ball);     this.mphysicsworld.registerphysicsconnector(new physicsconnector(ball, bodyball, true, true)); 

and here code check goal:

    @override     public void onupdate(final float psecondselapsed) {         if(uppergoal.collideswith(ball)) {             scorea = scorea+1;             scoretext.settext(scorea+" - " + scoreb);             bodyball.settransform(new vector2(camera_width/2,camera_height/2),0);                            uppergoal.setcolor(1, 0, 0); 

i try bodyball.setposition(100,100,0).

body class has no method setposition. set new coordinates, use

bodyball.settransform(new vector2(x/32,y/32), 0); 

you need divide 32 because box2d not operates in pixels


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -