Hola, tengo este codigo, de la orientación de un enemigo, que en teoria detecta si ha cambiado de posición y lo cambia por su imagen correspondiente.

if (x == xprevious && y == yprevious)
{
    image_speed = 0;
}

if xprevious < x  {
if (image_index <= 9 || image_index >= 12)
        {
            image_index = 9;

}
if xprevious > x  {
if (image_index <= 6 || image_index >=9 )
        {
            image_index = 6;
}
if yprevious < y 
{
if (image_index <= 3 || image_index >= 6)
        {
            image_index = 3;
}
if yprevious > y 
{
if (image_index <= 0 || image_index >= 3)
        {
            image_index = 0;
}
}}}}

el tema es que no detecta que haya un cambio en la x ni en la y, ( y si, se está moviendo ).

Este es el codigo en create
hp = 30;
speed = choose ( 0.5,1,1.5)
direccion = choose (0,90,180 )
direction = direccion
image_speed = 0.3 * speed

Step

depth = -y
if (place_meeting(x,y,obj_bala))
{
    var magiaprop
    magiaprop = instance_nearest(x,y,obj_bala);
   
    hp -= global.damage; // **

{
}}

if ( hp < 0 )
{
instance_destroy(){
}}
//pared
if( place_meeting(x,y+ 12,obj_room))  {direction = 90} //arriba
if( place_meeting(x,y - 12,obj_room)) {direction = 270} //abajo
if( place_meeting(x - 12,y,obj_room)) {direction = 0} //izquierda
if( place_meeting(12+x,y,obj_room)) {direction = 180} //derechaa
//pared enemigos
if( place_meeting(x,y+ 12,par_enemy))  {direction = 90} //arriba
if( place_meeting(x,y - 12,par_enemy)) {direction = 270} //abajo
if( place_meeting(x - 12,y,par_enemy)) {direction = 0} //izquierda
if( place_meeting(12+x,y,par_enemy)) {direction = 180} //derechaa

//orientacion


if (x == xprevious && y == yprevious)
{
    image_speed = 0;
}

if xprevious < x  {
if (image_index <= 9 || image_index >= 12)
        {
            image_index = 9;

}
if xprevious > x  {
if (image_index <= 6 || image_index >=9 )
        {
            image_index = 6;
}
if yprevious < y 
{
if (image_index <= 3 || image_index >= 6)
        {
            image_index = 3;
}
if yprevious > y 
{
if (image_index <= 0 || image_index >= 3)
        {
            image_index = 0;
}
}}}}


Muchas gracias !

#1 Marzo 12, 2018, 08:24:29 AM Ultima modificación: Marzo 13, 2018, 06:52:53 PM por 3dgeminis
Porque tenes un sprite de 13 imagenes si solo usas 4 ?
En lugar ir comprobando xprevious e y previous deberias usar direction que ya estas usando, para cambiar de imagen.