math.sin()

类型 函数
math.*
返回值 数字
修订 版本 2024.3703
关键词 正弦,sin
另请参阅 math.asin()
math.pi
math.cos()

概述

返回 x(以弧度表示的角度)的正弦值。结果是一个介于 [-1, 1] 范围内的数字。

语法

math.sin( x )
x (必填)

数字. 以弧度表示的角度。

示例

-- move a circle along a path
local myCircle = display.newCircle( 0, display.viewableContentHeight/2, 20 )
local t, p = 0, 0.7
myCircle:setFillColor( 1, 0, 0 )
local function onFrame( event )
    myCircle.x = display.viewableContentWidth/2 + 100 * math.cos(10*t - p)
    myCircle.y = display.viewableContentHeight/2 - 100 * math.sin(10*t)
    t = t + 5
end
Runtime:addEventListener( "enterFrame", onFrame )