Author Topic: Setting the ground sprite for the hero with different types of grass and water  (Read 246 times)

alexgleason

  • Full Member
  • ***
  • Posts: 124
  • Vegan on a Desert Island
    • View Profile
    • Vegan on a Desert Island
My game has several different types of grass and water. Is there a way to set ground1 and ground2 to a different sprite when entering a different area?

I'd also be curious if it's possible to set the direction of the ground based on the hero's direction. eg, when the hero faces left ground2 looks different.

Thanks!
RIP Aaron Swartz

llamazing

  • Full Member
  • ***
  • Posts: 168
    • View Profile
Is there a way to set ground1 and ground2 to a different sprite when entering a different area?

I don't know if it is possible to change the sprite itself, but it should be possible to change the animation of the sprite at least to give it a different appearance. You'll probably have to use sprite:on_animation_changed(animation) to manually change it every time it updates, though.

I'd also be curious if it's possible to set the direction of the ground based on the hero's direction. eg, when the hero faces left ground2 looks different.

I'd imagine that the following would work:
Code: (lua) [Select]
function hero:get_sprite"tunic":on_direction_changed(animation, direction)
  local ground_sprite = hero:get_sprite"ground"
  if ground_sprite then
    ground_sprite:set_direction(direction)
  end
end

froggy77

  • Full Member
  • ***
  • Posts: 127
    • View Profile
In this is a similar topic "Multiple ground sprites?" , we learn that there should be a new feature in version 1.6, but in fact I'm not sure it exists.  :'(

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1168
    • View Profile
You can do it even more easily in 1.6, now that you can add any sprite to the hero.

froggy77

  • Full Member
  • ***
  • Posts: 127
    • View Profile
ah OK, good news, but if there is somewhere a simple example, I'm interested. ;)