Hi all
I’m messing around trying to get an animated sprite to face the direction that it is moving, but I’m hopelessly lost. I made a little example of an animated sprite that is moving diagonally across the screen, what I want to do is get the top of the head of the sprite to point in the direction that it is moving.
Is there some kind of translate and rotate trick I need to use?
I eventually want the sprite to follow where I am touching on screen, and the animation to face the direction that it’s moving.
Anyone able to give me some pointers?
Thanks in advance!
-- Animation Test
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
chop1=readImage("Planet Cute:Character Boy")
chop2=readImage("Planet Cute:Character Cat Girl")
chop3=readImage("Planet Cute:Character Horn Girl")
chop4=readImage("Planet Cute:Character Pink Girl")
chop5=readImage("Planet Cute:Character Princess Girl")
anim={chop1,chop2,chop3,chop4,chop5}
animNo=1
animTimer=0
animDelay=0.1
charY=HEIGHT
charX=0
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(0, 0, 0, 255)
animTimer=animTimer+DeltaTime
if animTimer>animDelay then
animNo=animNo+1
if animNo>#anim then
animNo=1
end
animTimer=0
end
sprite(anim[animNo],charX,charY)
charY=charY-3
charX=charX+1.5
end