类型 函数 库 math.* 返回值 数字 修订 版本 2024.3703 关键词 余弦,cos 另请参阅 math.acos()
math.pi
math.sin()
返回 x(以弧度表示的角度)的余弦值。结果是一个介于 [-1, 1] 范围内的数字。
math.cos( x )
数字. 以弧度表示的角度。
-- animate a circle along a path
local ox, oy = display.contentCenterX, display.contentCenterY
local myCircle = display.newCircle( ox, oy, 20 )
myCircle:setFillColor( 1, 0, 0 )
local function onFrame( event )
myCircle.x = ( myCircle.x + 5 ) % display.viewableContentWidth
myCircle.y = oy - math.cos( myCircle.x/20 ) * 100.0
end
Runtime:addEventListener( "enterFrame", onFrame )