I believe that rotate() rotates around 0,0 and so to get it to rotate around a point you translate, which it appears you’ve done. I don’t understand why you need the x,y in rotate?
@Prynok .It’s the same when you’re doing an animation.
Why?: in your example when translate then sprite, you are giving the position where the image will appear, then when u rotate , you are giving only the value of z, when you rotate an image, you cant not pass the values ??of x, y, these will move when you touch the screen giving the target in the same sprite
sprite("Custom2", WIDTH/2-300,HEIGHT/2-200, 8, 36)
function setup()
mensaje = {x=WIDTH/2,y=HEIGHT/2+700,z =100}
end
function draw()
background(0,0,0,0)
tween(1,mensaje,{x = WIDTH/2,y = HEIGHT/2+150, z = 100},
{easing = tween.easing.backIn,
loop = tween.loop.once})
pushMatrix()
translate(mensaje.x,mensaje.y)
rotate(mensaje.z)
sprite("Cargo Bot:Codea Logo")
popMatrix()
end
@Prynok There is no easy way to do what you want. rotate() doesn’t take three variables, it only takes one or four. If you use one, it’s degrees for rotation in 2D. If you use four, the first variable is degrees, and the next three are x, y, and z. The last three are either 0 or 1. Four is used for 3D rotation.
@SkyTheCoder: “The last three are either 0 or 1.” If you mean that literally then you’re wrong. The last three inputs to the rotate function specify the axis to rotate about so can be anything, although 0,0,0 is a silly choice (not actually sure what it will do with that input).
rotate(angle,x,y,z) rotates by angle about the axis (x,y,z). There’s no function for “rotate about a point”. What you have to do is what @JakAttak says: translate so that the point you want to rotate about is at the origin, do the rotation, and then translate back again.
function draw()
background(40,40,50)
translate(WIDTH/2,HEIGHT/2)
rotate(CurrentTouch.y)
translate(-WIDTH/2,-HEIGHT/2)
sprite("Cargo Bot:Codea Logo",WIDTH/2,300)
end
@SkyTheCoder It’s a 3D thing so if you don’t have the matrices set up correctly then it’s easy to rotate your stuff off the screen (remember that things get clipped if they are too close or too far away as well).