Author Topic: Sprite animation names  (Read 2469 times)

Mimiga

  • Newbie
  • *
  • Posts: 6
    • View Profile
Sprite animation names
« on: December 11, 2014, 09:58:14 pm »
Hi, I was wondering how the game defines what the player's sprite is. In the defaults it's something like hero/tunic1, but I want to choose between two different characters so I want to name them what I want (like "hero/player1" or "hero/player2"). I didn't think I found anything under the documentation. Where do I go to make the engine make the default hero sprite "hero/player1" other than the default "hero/tunic1"? Also, are the animation names like "walking" and "plunging" concrete in that they MUST be named that in order for the editor to read them correctly in order to walk? Is it possible to add a custom animation like "crying" and have it be used by calling sprite:set_animation?
« Last Edit: December 11, 2014, 10:01:46 pm by Mimiga »

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1177
    • View Profile
Re: Sprite animation names
« Reply #1 on: December 12, 2014, 08:56:52 am »
Hi, I was wondering how the game defines what the player's sprite is. In the defaults it's something like hero/tunic1, but I want to choose between two different characters so I want to name them what I want (like "hero/player1" or "hero/player2"). I didn't think I found anything under the documentation. Where do I go to make the engine make the default hero sprite "hero/player1" other than the default "hero/tunic1"?
"hero/tunicX" is the default sprite, but you can change it with hero:set_tunic_sprite_id(): http://www.solarus-games.org/doc/latest/lua_api_hero.html#lua_api_hero_set_tunic_sprite_id

Also, are the animation names like "walking" and "plunging" concrete in that they MUST be named that in order for the editor to read them correctly in order to walk? Is it possible to add a custom animation like "crying" and have it be used by calling sprite:set_animation?
Animations like "walking" and "plunging" are mandatory (and automatically triggered by the engine) but you can add other ones. And you can start them with hero:set_animation(): http://www.solarus-games.org/doc/latest/lua_api_hero.html#lua_api_hero_set_animation

Mimiga

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Sprite animation names
« Reply #2 on: January 13, 2015, 03:35:08 am »
hi I'm back again. Thanks for the previous answers they helped me understand the engine better. I have another question now.

I have a script thats under the game_manager file, so when the game starts the game_manager loads it, like the dialogue_box file. other than the constructor I have only one function in there which I call from an item. it's supposed to show a picture. the function is successfully called, no problem there, but an error occurs when attempting to show the picture:
Code: [Select]
Error: In timer callback: [string "scripts/picture.lua"]:26: bad argument #1 to 'draw' (sol.surface expected, got nil)and I tried it with the exact code from the first tutorial with the challenge_accepted picture and it doesn't seem to be loading my picture at all. this is the function

Code: [Select]
function picture_manager:show_picture()

local hello_1 = sol.surface.create("hello.png")
hello_1:draw(screen,50,50)

end

I don't know LUA very well so I'm not sure how to check how the function is working (though I'm assuming it does not load the picture because when attempting to draw, it is nil). Should I be using something different because it's a child of game_manager which is a child of main? Since it works fine on main, but not here. Or am I doing something else totally wrong?


EDIT: Please ignore all of the above I am very dumb. I forgot this crucial part:
Code: [Select]
function sol.main:on_draw(screen)
end
However, that still brings me to my other question: every time I want to draw a file to the screen, do I have to encase it in this function? Furthermore, I see that trying to use .JPGs causes the game to crash, so I assume the engine can't handle the image data of a jpeg. Is there documentation on what files that it accepts on the create function? In the documentation it does not specify what files are able to be loaded through sol.surface.create.

Question 2: Is it possible to have z-indices for pictures? Like make a picture show behind the dialogue box, or to switch a picture's z-index to have one on top of another? Or is it because the surface IS the entire screen that it goes over everything and is therefore impossible?
« Last Edit: January 13, 2015, 03:49:55 am by Mimiga »

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1177
    • View Profile
Re: Sprite animation names
« Reply #3 on: January 13, 2015, 09:12:06 am »
Code: [Select]
function sol.main:on_draw(screen)
end
However, that still brings me to my other question: every time I want to draw a file to the screen, do I have to encase it in this function? Furthermore, I see that trying to use .JPGs causes the game to crash, so I assume the engine can't handle the image data of a jpeg. Is there documentation on what files that it accepts on the create function? In the documentation it does not specify what files are able to be loaded through sol.surface.create.
Yes, in this one or in another on_draw() function. game:on_draw() is called at each frame but only during a game, and sol.main:on_draw() is called at each frame even before starting a game (like in the title screen). There is also menu:on_draw() if you choose to use a menu. In this case, add the menu to the game and you don't have to redefine game:on_draw().
JPG images should work. What is the crash exactly? Is there an error message or an error.txt file?

Also, don't forget that on_draw() is called at each frame, so you should load the file once before and them only draw it at each frame.

Question 2: Is it possible to have z-indices for pictures? Like make a picture show behind the dialogue box, or to switch a picture's z-index to have one on top of another? Or is it because the surface IS the entire screen that it goes over everything and is therefore impossible?
The order is simply defined by when you call the draw() functions. For example, if you draw two objects, the second one will be drawn after the first one and therefore above it.

Mimiga

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Sprite animation names
« Reply #4 on: January 13, 2015, 08:18:56 pm »
About JPG:
No there's actually nothing in the error logs, it crashes before it can even output anything there. And by crash it simply freezes when I assume it's about to load the picture with sol.surface.create. Using a PNG instead outputs everything just fine but using JPG, it freezes the game and tells me to force close.

Mimiga

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Sprite animation names
« Reply #5 on: January 16, 2015, 04:42:26 am »
Sorry to pester you again  :-[ I'm having fun with the engine...

I am trying to increase the size of the screen from 320x240 to a larger one. I searched and found this topic: http://forum.solarus-games.org/index.php/topic,36.msg133.html#msg133, which asks the same question I am about increasing size. I did the same thing as shown but my window screen doesn't change, from 320. This is what's in quest.dat


Code: [Select]
quest{
  solarus_version = "1.3",
  write_dir = "sample_quest",
  title_bar = "WHEEEEEEEEEEEE!!",
  normal_quest_size = "960x720",
  min_quest_size = "320x240",
  max_quest_size = "960x720"
}

Is it deprecated? Or did I do it wrong?

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1177
    • View Profile
Re: Sprite animation names
« Reply #6 on: January 16, 2015, 10:09:27 am »
It should work, maybe there is a bug. Can you send me your project?

Mimiga

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Sprite animation names
« Reply #7 on: January 22, 2015, 12:06:58 am »
Sure, this is it: http://www.mediafire.com/download/tm2173mrflfdns8/data.rar

I only changed a little things from the sample quest. In quest.dat you can see I changed the quest sizes, but is still 320x240. Did I do something wrong?