how do i get a sprite to display properly?

Post Reply
aximx51v
Member
Posts: 60
Joined: Fri Dec 07, 2012 03:47

how do i get a sprite to display properly?

by aximx51v » Post

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:

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?

Code: Select all

setsprite({x=0,y=0}, 1, 0, true)
currently i have it in entity.on_step as:

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?

prestidigitator
Member
Posts: 647
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Post

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.

aximx51v
Member
Posts: 60
Joined: Fri Dec 07, 2012 03:47

by aximx51v » Post

i tried

Code: Select all

some_entity.on_activate = function(self, staticdata)
    self.object:setsprite({x=0,y=0}, 1, 1, true)
end
but no luck..
Last edited by aximx51v on Thu Mar 07, 2013 13:30, edited 1 time in total.

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

Use

Code: Select all

visual = "upright_sprite",
instead of

Code: Select all

visual = "sprite",

aximx51v
Member
Posts: 60
Joined: Fri Dec 07, 2012 03:47

by aximx51v » Post

PilzAdam wrote:Use

Code: Select all

visual = "upright_sprite",
instead of

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?

User avatar
PilzAdam
Member
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam
Location: Germany

by PilzAdam » Post

aximx51v wrote:
PilzAdam wrote:Use

Code: Select all

visual = "upright_sprite",
instead of

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/bl ... .txt#L1216

leetelate
Member
Posts: 205
Joined: Thu Aug 29, 2013 18:07
Location: 한인 타운, Huntsville,Alabama,USA

by leetelate » Post

plizadam ++ thanks for telling this very much

now it is line 1873 in current document!
Last edited by leetelate on Fri Sep 13, 2013 00:38, edited 1 time in total.
MT IS MC'S SMARTER BROTHER
minetest 0.4.8 compiled from latest git on linux mint 15 with qjoypad and wired 360 controller
freeminer, pilztest, buildcraft and next are the idea factories
my minetest page is http://1337318.zymichost.com if zymic isn't down - meh, it is free...

Post Reply

Who is online

Users browsing this forum: No registered users and 53 guests