Page 1 of 1

how do i get a sprite to display properly?

PostPosted: Wed Mar 06, 2013 23:40
by aximx51v
I can't seem to get a sprite image to display like i want (i want it to display the way 2d mobs do in sapiers animals mod)
i have:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
entity={
    physical = false,
    timer=0,
    physical = true,
    visual = "sprite",
    visual_size = {x=4,y=4},
    textures = {"image.png^[makealpha:128,0,0^[makealpha:128,128,0"},
    sprite_div = {x=6,y=1},
    initial_sprite_basepos = {x=0, y=0},
    --
    lastpos={},
    collisionbox = {-0.8,-0.8,-0.8,0.8,0.8,0.8},
    full = false,
    attached = ""

but where do i put this part?
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
setsprite({x=0,y=0}, 1, 0, true)

currently i have it in entity.on_step as:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
entity.on_step = function(self, dtime)
    self.object:setsprite({x=0,y=0}, 1, 0, true)

but it doesn't display right. i see the whole image (not just the tile i want to) and it rotates so that the image is always facing me

how to fix this?

PostPosted: Thu Mar 07, 2013 07:05
by prestidigitator
From the LuaEntitySAO reference page, I'd guess you just have to set it once if you are using set_horiz_by_yawpitch=true. So I would just do it in the entity's "on_activate(self, staticdata, dtime_s)" callback. I'd also guess that you don't want a framelength of zero, but I confess I'm not entirely sure exactly how framelength or set_horiz_by_yawpitch work.

PostPosted: Thu Mar 07, 2013 13:29
by aximx51v
i tried
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
some_entity.on_activate = function(self, staticdata)
    self.object:setsprite({x=0,y=0}, 1, 1, true)
end

but no luck..

PostPosted: Thu Mar 07, 2013 16:36
by PilzAdam
Use
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
visual = "upright_sprite",

instead of
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
visual = "sprite",

PostPosted: Fri Mar 08, 2013 13:30
by aximx51v
PilzAdam wrote:Use
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
visual = "upright_sprite",

instead of
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
visual = "sprite",


well, i still have the same image(all 6 faces smushed in to one image), but it's not self aligning to my view angle anymore.
how many faces does an upright sprite support? can it have 6 sides?

PostPosted: Fri Mar 08, 2013 16:06
by PilzAdam
aximx51v wrote:
PilzAdam wrote:Use
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
visual = "upright_sprite",

instead of
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
visual = "sprite",


well, i still have the same image(all 6 faces smushed in to one image), but it's not self aligning to my view angle anymore.
how many faces does an upright sprite support? can it have 6 sides?

An uprigight sprite is just a flat texture, so it supports 2 textures (one for each side).
You can rotate it with https://github.com/minetest/minetest/blob/master/doc/lua_api.txt#L1216

PostPosted: Fri Sep 13, 2013 00:35
by leetelate
plizadam ++ thanks for telling this very much

now it is line 1873 in current document!