how do i get a sprite to display properly?

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

how do i get a sprite to display properly?

by aximx51v » Wed Mar 06, 2013 23:40

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?
 

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

by prestidigitator » Thu Mar 07, 2013 07:05

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 » Thu Mar 07, 2013 13:29

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..
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

by PilzAdam » Thu Mar 07, 2013 16:36

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",
 

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

by aximx51v » Fri Mar 08, 2013 13:30

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?
 

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

by PilzAdam » Fri Mar 08, 2013 16:06

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
 

leetelate
Member
 
Posts: 205
Joined: Thu Aug 29, 2013 18:07

by leetelate » Fri Sep 13, 2013 00:35

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...
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 4 guests

cron