[Help] Sprite rendering

Started by YoshiMario2000, September 18, 2016, 09:25:30 PM

Previous topic - Next topic
Wondering If I can change they way sprites are rendered. Rather than having a sprite that has a higher Y-value than the hero be rendered over them, I want the sprite to be rendered beneath the hero.
This signature was way too long before, but now it's short!
Also, I am Still Alive!
On ad Off I go!

Do you ever get the feeling that the fandom of a product(s) ruin the potential that you could have had to enjoy the product?

Sprites are currently attached to entities, so I guess you are trying to draw some entity under the hero, isn't it? If so, yes, it is possible to do so, and the Lua API should solve your problems. If you still have problems to do it, then you should explain with more details what you are trying to do, so that we can help you.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

If the entity is a custom entity, there is a function custom_entity:set_drawn_in_y_order() to specify if you want it to be displayed in Y order or in Z order.

Quote from: Christopho on September 19, 2016, 08:51:01 AM
If the entity is a custom entity, there is a function custom_entity:set_drawn_in_y_order() to specify if you want it to be displayed in Y order or in Z order.
Ah, so THATS where I saw something along the lines of that, I thought that It applied to all entities.
Guess I was wrong...

Quote from: Diarandor on September 19, 2016, 12:59:27 AM
Sprites are currently attached to entities, so I guess you are trying to draw some entity under the hero, isn't it? If so, yes, it is possible to do so, and the Lua API should solve your problems. If you still have problems to do it, then you should explain with more details what you are trying to do, so that we can help you.
What I'm trying to do is to have a block that has a higher Y-value than the hero to be displayed underneath the hero.
I'm working with the side scrolling script and am displaying the tiles in a similar fashion to Kirby superstar saga. Which Includes entities like blocks. The behavior is fine other than the odd rendering of the sprites when the hero overlaps the block.
This signature was way too long before, but now it's short!
Also, I am Still Alive!
On ad Off I go!

Do you ever get the feeling that the fandom of a product(s) ruin the potential that you could have had to enjoy the product?

If your block has a sprite whose size is greater than 16, then it gets displayed in Y order. Like statues in my games. This will be customizable one day, but as a workaround you can always make a sprite higher than 16 pixels with simply some transparency above :)

QuoteWhat I'm trying to do is to have a block that has a higher Y-value than the hero to be displayed underneath the hero.
I'm working with the side scrolling script and am displaying the tiles in a similar fashion to Kirby superstar saga. Which Includes entities like blocks. The behavior is fine other than the odd rendering of the sprites when the hero overlaps the block.

If I understood correctly, you are trying to make built-in blocks in 2D side-scrolling and allow to display the hero correctly over it, isn't it? I still do not understand which is the problem, unless it is what Christopho says: that the sprite of your block is too big. If that is the case, you could use a custom entity instead, but the simplest way would be to use a 16x16 sprite. If you still have some problem, we would need more info to help more; if so, recall that an image is worth a thousand words.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

This signature was way too long before, but now it's short!
Also, I am Still Alive!
On ad Off I go!

Do you ever get the feeling that the fandom of a product(s) ruin the potential that you could have had to enjoy the product?

Thanks for the image! This shows that Christopho was right, your sprite is not 16x16, and therefore you will need to use some "ugly" workaround (or wait until Solarus adds more customization to the built-in blocks). I give you two possible workarounds that should work, but you will need to work a bit:

-One of them is just using custom entities instead of built-in blocks. Note that this allows to use several sprites for a custom block, which would solve your problem because you could display the above part behind the hero. But you would need to code all the block features in Lua...

-The other workaround is to create, for each block, a rectangular and (traversable) custom entity with the above part of the sprite. That custom entity should follow the block (that can be done with a timer which is called each millisecond, for instance). These custom entities can be easily created from the map script using a loop on all entities of block type.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Well, Seeing as that improved built-in functionality probably won't happen until 1.6 or something, I think I'll just go the custom entity route. Shouldn't be hard right?
This signature was way too long before, but now it's short!
Also, I am Still Alive!
On ad Off I go!

Do you ever get the feeling that the fandom of a product(s) ruin the potential that you could have had to enjoy the product?

I think both solutions are easy. The second solution requires less work, so it is probably better and quicker. Anyway, it's your choice.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Creating a custom-entitified block is relatively easy, you might need Diarandors Direction and animation fix first, and disable the y-order drawing when the block is at a certain point

This is the recommanded workaround as for now, if you plan to use a block which has a pixel value higher then 16x16