This site requires JavaScript, please enable it in your browser!
Greenfoot back
joelORTEGA
joelORTEGA wrote ...

2019/6/16

obtener ubicación en la que inicia mi personaje

joelORTEGA joelORTEGA

2019/6/16

#
hello could help me with a code, I want that when my character touches one or another thing I lower a life and locate it where I start, but what happens is that when I am in another world it does not come out in the position in which it starts, I can do. This is my code: int x, y; x = 298; y = 42;          if (isTouching (comida.class)) {              cont = cont + 1;              this.getWorld (). showText ("score:" + cont, 500.30);          } if (isTouching (floor.class) || isTouching (enemy1.class)) {                x = this.getX ();                y = this.getY ();              contlife--;              this.getWorld (). showText ("life:" + contlife, 100.30);              setLocation (y, x);               if (contlife == 0) {                  gameov ();              }          } otherwise, when life is = 0 does not change the world ?? I hope you help me thanks
Super_Hippo Super_Hippo

2019/6/17

#
Maybe this helps to replace your setLocation method call in which you use the current position of the actor (overriding 298/42) and swap the x and y...
setLocation(298, 42);
Remove all X and Y codes.
joelORTEGA joelORTEGA

2019/6/17

#
thank you
You need to login to post a reply.