A couple of questions about AnAL and such

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Delibrete
Prole
Posts: 37
Joined: Mon Dec 05, 2011 11:51 am

A couple of questions about AnAL and such

Post by Delibrete »

Hello,

I'm currently experimenting with love, trying to build my knowledge base of the framework and the lua language and I'm using the AnAL library for animations. Here are the problems I'm facing:
  • >The robot is slightly flashing when he moves

    >You can see part of the robots knee in behind him when he walks (fig.1)
fig.1
Image

Also, how would I go about making the mouse in the center of both of the guns?

Image

Thank you.
Attachments
robot_example.love
(3.96 KiB) Downloaded 153 times
LiquidDandruff
Prole
Posts: 18
Joined: Fri Dec 16, 2011 11:29 pm

Re: A couple of questions about AnAL and such

Post by LiquidDandruff »

hello, im new to lua and love and i too am also using the anal library. I got the same problem as you too when i first started but i sort of fixed it after a few minutes of fiddling. Go in your image editing program and sort of center your sprite and border each frame with say 2 pixels of transparency, so when anal is iterating through the frames you wont see any artifacts.

Example, your spritesheet has 4 frames and each frame is say 50 pixels wide and 80 pixels tall. Instead of having the finished sprite sheet 200 pixels by 160 pixels, space each frame by 2 pixels of transparency -> 4(50+2) = finished sprite sheet width = 208. Go to the next power of 2 if you have to. Now in your code, instead of having the width of each frame set at 50 pixels, make it 52.

I also have a bit of flashing in my animation too if i do things with love.graphics.translate(). I don't know how to fix this though.

The angle seems to be okay- it's not really noticeable, but if you want to modify it you might need to make a new angle variable and with it, calculate its dx separately - you're basing the angles of both arms with the x of one. example:

Code: Select all

        leftarmx = 64
        rightarmx = 70 --idk made it up, lets say it is :)
	xmouse = love.mouse.getX()
	ymouse = love.mouse.getY()
	
	dxleft = (leftarmx+2+4) - xmouse
        dxright = (rightarmx+2+4)-xmouse
	dy = 82+4 - ymouse
	
	angleleft = math.atan2(dxleft,-dy)
        angleright = math.atan2(dxright,-dy)
then draw it with the appropriate angles!
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: A couple of questions about AnAL and such

Post by Taehl »

That little line thing is actually caused by all graphics hardware, as a result of filtering. Without getting all technical, all you need to do is have at least one pixel of transparency around every sprite.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
Ellohir
Party member
Posts: 235
Joined: Sat Oct 22, 2011 11:12 pm

Re: A couple of questions about AnAL and such

Post by Ellohir »

Taehl wrote:That little line thing is actually caused by all graphics hardware, as a result of filtering. Without getting all technical, all you need to do is have at least one pixel of transparency around every sprite.
I was watching some weird things on my tiles while I was moving, knowing they were perfectly aligned. It's nice to know it can be that.

To check if it's a title problem I recommend ASEprite. It's a very small graphic program. Click on "Import sprite sheet" and shows two lines making the first sprite and creating a grid for the rest of the image. Move that lines and you know exactly where and how you were drawing out of a sprite :crazy:
LiquidDandruff
Prole
Posts: 18
Joined: Fri Dec 16, 2011 11:29 pm

Re: A couple of questions about AnAL and such

Post by LiquidDandruff »

LiquidDandruff wrote: I also have a bit of flashing in my animation too if i do things with love.graphics.translate(). I don't know how to fix this though.
Fix! It flickers because of floating point arithmetic, so rounding the values to closest whole number works great.

http://lua-users.org/wiki/SimpleRound

Code: Select all


function round(num, idp)
	local mult = 10^(idp or 0)
	return math.floor(num * mult + 0.5) / mult
end



	local xzoom,yzoom = round((mousetoarea.x-self.x)*zoompanfactor),((mousetoarea.y-self.y)*zoompanfactor) --rounds it to nearest whole number
	love.graphics.translate(screenWc-self.x-xzoom, screenHc-self.y-yzoom)
and also round drawing calls
actually, better fix is to just round the xs and ys at drawing call like so

Code: Select all

anim:draw(round(self.x),round(self.y), self.r, self.facing, 1, 25, 25)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 7 guests