I am kind of new to Lua, just so you know!
I just wonder, if you have a sprite,line or a object and you want them to rotate
when touching that or if that variable is equal to that, then what should you do?
I know that there is “rotate” and “self.joint” but if it is as “easy” as that, how would you
write it?
Hope you’re looking for this.
function setup()
img=readImage("Cargo Bot:Star Filled")
angle=0
end
function draw()
background(0, 0, 0, 255)
if touching then
angle = angle + 1
end
pushMatrix()
translate(WIDTH/2,HEIGHT/2) -- you need to do this as rotation is done about 0,0
rotate(angle) --angle to rotate the sprite by
sprite(img,0,0) --0,0 as I translated to the position i wanted the sprite to be drawn
popMatrix()
end
function touched(touch)
if touch.state==BEGAN then
if WIDTH/2-95<touch.x and touch.x<WIDTH/2+95 and
HEIGHT/2-92<touch.y and touch.y<HEIGHT/2+92 then --check if touching sprite or not
touching=true
end
elseif touch.state==ENDED then
touching=false
end
end
Got re posted don’t know how!!!
Thanks, see how you have done it.