【问题标题】:Unexpected Token 'function'意外的令牌“功能”
【发布时间】:2016-09-05 15:36:18
【问题描述】:
Strict
Import mojo

Function Main:Int()
    CreateMapArray()
    Return 0
End

Function DrawRect:Int(x:Int, y:Int, w:Int, h:Int)

Function CreateMapArray:Int()
    Local MapArray:Int[10][]      'This code is for creating a 2D array to act as a map.
    For Local i:Int = 0 Until MapArray.Length()
        MapArray[i] = New Int[10]
    End
    Print("Here")
    For Local j:Int = 0 Until MapArray.Length()    'This code is to know where to put each rectangle in the 2D array/map.
        MapArray[j][9] = 1
        MapArray[0][j] = 1
        MapArray[9][j] = 1
        MapArray[j][0] = 1
        MapArray[j][8] = Rnd(0,2)
        Print(MapArray[j][8])
    End 
    For Local k:Int = 0 Until MapArray.Length()      'This code if for creating the rectangles.
        For Local l:Int = 0 Until MapArray.Length()
            If MapArray[k][l] = 1 Then
                DrawRect:Int(k, l, 5, 5)
            End
        End
    End
    Return 0
End

在此,我在“Function DrawRect:Int(x:Int, y:Int, w:Int, h:Int)”行收到了一个意外的标记“函数”错误。顺便说一句,这是在 Monkey X 免费版上完成的。提前感谢您的帮助。

【问题讨论】:

  • 嗨,OP,您的问题解决了吗?如果我的回答提供了解决方案,请考虑接受。它可以帮助社区:)

标签: function token monkey-x


【解决方案1】:

您没有使用End 关闭DrawRect 函数。

Function DrawRect:Int(x:Int, y:Int, w:Int, h:Int)

End <- missing bit

或者,您必须完全删除 DrawRect 函数声明。

【讨论】:

    猜你喜欢
    • 2017-11-08
    • 1970-01-01
    • 2019-03-29
    • 2021-08-11
    • 1970-01-01
    • 1970-01-01
    • 2020-09-08
    • 1970-01-01
    • 2018-10-19
    相关资源
    最近更新 更多