Hola a todos.
He estado trabajando con este c?digo pero no puedo hacer que el personaje cambie de sprite cuando apunta hacia arriba y est? en el aire. Quiz? ustedes puedan explicarme qu? estoy haciendo mal. El c?digo est? en el evento step del personaje.
// saltar ascenso //
if (vspeed < 0)
{
if (right == true) { sprite_index = ascender_d; }
if (left == true) { sprite_index = ascender_i; }
}
// saltar descenso //
if (vspeed > 0)
{
if (left == true) { sprite_index = descender_i; }
if (right == true) { sprite_index = descender_d; }
}
// caminar //
if (!place_free(x,y+1))
{
if (right == true) { sprite_index = andar_d; }
if (left == true) { sprite_index = andar_i; }
}
// quieto //
if (left == true && !keyboard_check(vk_left) && !place_free(x,y+1))
{ sprite_index = quieto_i; }
if (right == true && !keyboard_check(vk_right) && !place_free(x,y+1))
{ sprite_index = quieto_d; }
// agachado //
if (down == true && right == true && !keyboard_check(vk_right)) { sprite_index = abajo_d; }
if (down == true && left == true && !keyboard_check(vk_left) ) { sprite_index = abajo_i; }
// agachado caminando //
if (down == true && keyboard_check(vk_right)) { sprite_index = abajo_andar_d }
if (down == true && keyboard_check(vk_left)) { sprite_index = abajo_andar_i }
// apuntar arriba //
if (up == true && right == true && !keyboard_check(vk_right)) { sprite_index = arriba_d; }
if (up == true && left == true && !keyboard_check(vk_left) ) { sprite_index = arriba_i; }
// apuntar arriba caminando //
if (up == true && keyboard_check(vk_right)) { sprite_index = arriba_andar_d }
if (up == true && keyboard_check(vk_left)) { sprite_index = arriba_andar_i }
Muchas gracias de antemano.
Lo encierro en la etiqueta GML para quien pueda ayudar (de momento es lo ?nico que puedo aportar).
[gml]// saltar ascenso //
if (vspeed < 0)
{
if (right == true) { sprite_index = ascender_d; }
if (left == true) { sprite_index = ascender_i; }
}
// saltar descenso //
if (vspeed > 0)
{
if (left == true) { sprite_index = descender_i; }
if (right == true) { sprite_index = descender_d; }
}
// caminar //
if (!place_free(x,y+1))
{
if (right == true) { sprite_index = andar_d; }
if (left == true) { sprite_index = andar_i; }
}
// quieto //
if (left == true && !keyboard_check(vk_left) && !place_free(x,y+1))
{ sprite_index = quieto_i; }
if (right == true && !keyboard_check(vk_right) && !place_free(x,y+1))
{ sprite_index = quieto_d; }
// agachado //
if (down == true && right == true && !keyboard_check(vk_right)) { sprite_index = abajo_d; }
if (down == true && left == true && !keyboard_check(vk_left) ) { sprite_index = abajo_i; }
// agachado caminando //
if (down == true && keyboard_check(vk_right)) { sprite_index = abajo_andar_d }
if (down == true && keyboard_check(vk_left)) { sprite_index = abajo_andar_i }
// apuntar arriba //
if (up == true && right == true && !keyboard_check(vk_right)) { sprite_index = arriba_d; }
if (up == true && left == true && !keyboard_check(vk_left) ) { sprite_index = arriba_i; }
// apuntar arriba caminando //
if (up == true && keyboard_check(vk_right)) { sprite_index = arriba_andar_d }
if (up == true && keyboard_check(vk_left)) { sprite_index = arriba_andar_i }[/gml]
Cita de: Hackware en Noviembre 09, 2010, 08:19:46 PM
Lo encierro en la etiqueta GML para quien pueda ayudar (de momento es lo ?nico que puedo aportar).
gracias sin ti no lo hubiera logrado (es enserio) no les entiendo bien a los scripts si no tienen colores.
bueno primero que nada tienes que poner esto en todos los codigos en los que no necesites estar saltando y solo lo tenias en los primeros 2
[gml]!place_free(x,y+1)[/gml]
y luego en la parte en donde esta dice vspeed<0 (que es cuando esta saltando) a?ades lo mismo que usabas para que mire hacia arriba tu personaje (obvio sin lo de !place_free(x,y+1)).
[gml]if (up == true && keyboard_check(vk_left){ sprite_index = arriba_salto_i}[/gml]
bueno as? quedar?a todo
[gml]
// saltar ascenso //
if (vspeed < 0)
{
if (right == true) { sprite_index = ascender_d; }
if (left == true) { sprite_index = ascender_i;
if (up == true && keyboard_check(vk_left){ sprite_index = arriba_salto_i }}
if (up == true && keyboard_check(vk_right){ sprite_index = arriba_andar_d }
}
// saltar descenso //
if (vspeed > 0)
{
if (left == true) { sprite_index = descender_i; }
if (right == true) { sprite_index = descender_d; }
}
// caminar //
if (!place_free(x,y+1))
{
if (right == true) { sprite_index = andar_d; }
if (left == true) { sprite_index = andar_i; }
}
// quieto //
if (left == true && !keyboard_check(vk_left) && !place_free(x,y+1))
{ sprite_index = quieto_i; }
if (right == true && !keyboard_check(vk_right) && !place_free(x,y+1))
{ sprite_index = quieto_d; }
// agachado //
if (down == true && right == true && !keyboard_check(vk_right) && !place_free(x,y+1)) { sprite_index = abajo_d; }
if (down == true && left == true && !keyboard_check(vk_left) && !place_free(x,y+1) ) { sprite_index = abajo_i; }
// agachado caminando //
if (down == true && keyboard_check(vk_right) && !place_free(x,y+1)) { sprite_index = abajo_andar_d }
if (down == true && keyboard_check(vk_left) && !place_free(x,y+1)) { sprite_index = abajo_andar_i }
// apuntar arriba //
if (up == true && right == true && !keyboard_check(vk_right) && !place_free(x,y+1)) { sprite_index = arriba_d; }
if (up == true && left == true && !keyboard_check(vk_left) && !place_free(x,y+1)) { sprite_index = arriba_i; }
// apuntar arriba caminando //
if (up == true && keyboard_check(vk_right) && !place_free(x,y+1)) { sprite_index = arriba_andar_d }
if (up == true && keyboard_check(vk_left) && !place_free(x,y+1)) { sprite_index = arriba_andar_i }[/gml]
Ha quedado perfecto. ?Muchas gracias a ambos por vuestra ayuda!
Por nada, que bueno que te sirvi?.