Skip to content

图文信息模块管理接口 Graphics ​

具体函数名及描述如下:

序号函数名函数描述
1MakeGraphicsText(...)创建文字板信息
2MakeflotageText(...)创建漂浮文字信息
3MakeGraphicsProgress(...)创建进度条信息
4MakeGraphicsArrowToPos(...)生成指向位置的箭头数据
5MakeGraphicsLineToPos(...)生成指向位置的线数据
6MakeGraphicsNavPathToPos(...)生成寻路引导线数据
7MakeGraphicsSurfaceToPos(...)生成指向位置的面数据
8MakeGraphicsArrowToActor(...)生成指向对象的箭头数据
9MakeGraphicsLineToActor(...)生成指向对象的线数据
10MakeGraphicsSurfaceToActor(...)生成指向对象的面数据
11MakeGraphicsImage(...)生成图片信息
12CreateGraphicsTxtByPos(...)在位置上创建图文
13CreateGraphicsTxtByActor(...)在生物身上创建文字板
14CreateflotageTextByPos(...)在位置上创建漂浮文字
15CreateflotageTextByActor(...)在生物身上创建漂浮文字
16CreateGraphicsProgressByPos(...)在位置上创建进度条
17CreateGraphicsProgressByActor(...)在生物身上创建进度条
18RemoveGraphicsByPos(...)删除位置上的图文
19RemoveGraphicsByObjID(...)删除生物的图文
20UpdateGraphicsTextById(...)更新文字板内容
21UpdateGraphicsProgressById(...)更新进度条进度
22CreateGraphicsArrowByActorToPos(...)生物指向位置箭头
23CreateGraphicsArrowByActorToActor(...)生物指向生物箭头
24CreateGraphicsArrowByPosToPos(...)位置指向位置箭头
25CreateGraphicsArrowByPosToActor(...)位置指向生物箭头
26CreateGraphicsLineByActorToPos(...)生物到位置线
27CreateGraphicsNavPathByActorToPos(...)生物到位置寻路引导线
28CreateGraphicsLineByActorToActor(...)生物到生物线
29CreateGraphicsLineByPosToPos(...)位置到位置线
30CreateGraphicsLineByPosToActor(...)位置到生物线
31CreateGraphicsSurfaceByActorToPos(...)生物到位置面
32CreateGraphicsSurfaceByActorToActor(...)生物到生物面
33CreateGraphicsSurfaceByPosToPos(...)位置到位置面
34CreateGraphicsSurfaceByPosToActor(...)位置到生物面
35ReplaceAllGraphics(...)迁移所有图文到目标对象
36CreateGraphicsImageByPos(...)在位置上创建图像
37CreateGraphicsImageByActor(...)在生物上创建图像
38GetInnerGraphicsOffset(...)获取内嵌图文偏移高度
39CreateBrushByPos(...)在位置上创建笔刷
40RemoveGraphicsByGraphicsID(...)按ID删除图文

MakeGraphicsText ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 文字板信息表;失败返回nil
  • 该方法的其他说明: 创建文字板图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsText([=[123]=], 16, 0, 1, true)

MakeflotageText ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 漂浮文字信息表;失败返回nil
  • 该方法的其他说明: 创建漂浮文字图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local data = Graphics:MakeflotageText([=[123]=], 16, 1)

MakeGraphicsProgress ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 进度条信息表;失败返回nil
  • 该方法的其他说明: 创建进度条图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsProgress(100, 100, [=[0xf44336]=], 1)

MakeGraphicsArrowToPos ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 箭头信息表;失败返回nil
  • 该方法的其他说明: 生成指向位置的箭头图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsArrowToPos(x, y, z, 1, [=[0xf44336]=], 1)

MakeGraphicsLineToPos ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 线信息表;失败返回nil
  • 该方法的其他说明: 生成指向位置的线图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsLineToPos(x, y, z, 1, [=[0xf44336]=], 1)

MakeGraphicsNavPathToPos ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 寻路线信息表
  • 该方法的其他说明: 生成指向位置的寻路引导线图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local playerarr = {playerId} --可见玩家数组

    local result = Graphics:MakeGraphicsNavPathToPos(x, y, z, 1, playerarr)

MakeGraphicsSurfaceToPos ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 面信息表;失败返回nil
  • 该方法的其他说明: 生成指向位置的面图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsSurfaceToPos(x, y, z, 1, [=[0xf44336]=], 1)

MakeGraphicsArrowToActor ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 箭头信息表;失败返回nil
  • 该方法的其他说明: 生成指向对象的箭头图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsArrowToActor(Player:GetHostUin(), 1, [=[0xf44336]=], 1)

MakeGraphicsLineToActor ​

  • 参数及类型: objid:number:对象数据,size:number:缩放值,color:number:颜色值(0xFFFFFF),itype:number:线ID
  • 返回值及类型:
    • info:table 线信息内容
  • 该方法的主要作用: 生成指向对象的线数据
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsLineToActor(Player:GetHostUin(), 1, [=[0xf44336]=], 1)

MakeGraphicsSurfaceToActor ​

  • 参数及类型: objid:number:对象数据,size:number:缩放值,color:number:颜色值(0xFFFFFF),itype:number:面ID
  • 返回值及类型:
    • info:table 面信息内容
  • 该方法的主要作用: 生成指向对象的面数据
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsSurfaceToActor(Player:GetHostUin(), 1, [=[0xf44336]=], 1)

MakeGraphicsImage ​

  • 参数及类型:
  • 返回值及类型:
    • obj:table 图片信息表;参数无效返回nil
  • 该方法的其他说明: 生成图片图文信息数据(供创建接口使用)
  • 具体使用案例如下:
lua
    local data = Graphics:MakeGraphicsImage([=[0_10004]=], 1, 100, 1)

CreateGraphicsTxtByPos ​

  • 参数及类型:
  • 返回值及类型:
    • id:number 图文实例ID;失败返回nil
  • 该方法的其他说明: 在指定位置创建图文信息(文字板等)
  • 具体使用案例如下:
lua
        y = y + 1

        local data = Graphics:CreateGraphicsTxtByPos(x, y, z, Graphics:MakeGraphicsText([=[123 test]=], 16, 0, 1, true), 0, 100, worldId)

CreateGraphicsTxtByActor ​

  • 参数及类型:
  • 返回值及类型:
    • id:number 图文实例ID;失败返回nil
  • 该方法的其他说明: 在生物身上创建文字板图文
  • 具体使用案例如下:
lua
    local data = Graphics:CreateGraphicsTxtByActor(playerId, Graphics:MakeGraphicsText([=[123 test]=], 16, 0, 1, true), {x = 0, y = 1, z = 0}, 20)

CreateflotageTextByPos ​

  • 参数及类型:
  • 返回值及类型:
    • id:number 图文实例ID;失败返回nil
  • 该方法的其他说明: 在指定位置创建漂浮文字
  • 具体使用案例如下:
lua
    local graphicsId = Graphics:CreateflotageTextByPos(x, y, z, Graphics:MakeflotageText([=[123 floatage text 111]=], 16, 1), 0, 0, worldId)

CreateflotageTextByActor ​

  • 参数及类型:
  • 返回值及类型:
    • id:number 图文实例ID;失败返回nil
  • 该方法的其他说明: 在生物身上创建漂浮文字
  • 具体使用案例如下:
lua
    local data = Graphics:CreateflotageTextByActor(playerId, Graphics:MakeflotageText([=[123 floatage text 222]=], 16, 1), {x = 0, y = 1, z = 0}, 100)

CreateGraphicsProgressByPos ​

  • 参数及类型:
  • 返回值及类型:
    • id:number 图文实例ID;失败返回nil
  • 该方法的其他说明: 在指定位置创建进度条
  • 具体使用案例如下:
lua
        local data = Graphics:CreateGraphicsProgressByPos(

            x, y, z, Graphics:MakeGraphicsProgress(100, 101, [=[0xf44336]=], 1),

            nil, nil, worldId)

CreateGraphicsProgressByActor ​

  • 参数及类型:
  • 返回值及类型:
    • id:number 图文实例ID;失败返回nil
  • 该方法的其他说明: 在生物身上创建进度条
  • 具体使用案例如下:
lua
    local data = Graphics:CreateGraphicsProgressByActor(playerId, Graphics:MakeGraphicsProgress(99, 100, [=[0xf44336]=], 1), {x = 0, y = 1, z = 0}, 100)

RemoveGraphicsByPos ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 删除指定位置上指定类型与ID的图文信息
  • 具体使用案例如下:
lua
        result = Graphics:RemoveGraphicsByPos(x, y, z, itype, gtype, worldId)

RemoveGraphicsByObjID ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 删除指定生物上指定类型与ID的图文信息
  • 具体使用案例如下:
lua
    local result = Graphics:RemoveGraphicsByObjID(playerId, 11, GraphicsType.Progress)

UpdateGraphicsTextById ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 按实例ID更新文字板图文的内容(字体、透明度等)
  • 具体使用案例如下:
lua
        local txtgraphis1 = Graphics:CreateGraphicsTxtByPos(x, y + 2, z, Graphics:MakeGraphicsText([=[创建的文本]=], 16, 0, 1, true), 0, 100, worldId)

        local txtgraphis2 = Graphics:CreateGraphicsTxtByPos(x + 1, y + 2, z, Graphics:MakeGraphicsText([=[创建的文本]=], 16, 0, 1, true), 0, 100, worldId)

        if txtgraphis1 and txtgraphis2 then

            self:ThreadWait(1)

        end

        local updateResult1 = false

        local updateResult2 = false

        if txtgraphis1 and txtgraphis2 then

            updateResult1 = Graphics:UpdateGraphicsTextById(txtgraphis1, "更新的文本1", 20, 0.5, false)

            updateResult2 = Graphics:UpdateGraphicsTextById(txtgraphis2, "更新的文本2", 20, 0.5, true)

        end

        --自动刷新文本

        local txtgraphis3 = Graphics:CreateGraphicsTxtByPos(x+3, y, z, Graphics:MakeGraphicsText("动态文本",16, 0, 1, true), 0 , 100, WorldId)

        if txtgraphis3 then

            local extendparam = {1,2,3}

            -- 脚本添加自动刷新图文信息功能

            local function getvalues(extendparam) --参数信息是添加监听时传入的参数

                return tostring(math.random(1, 9999))

            end

            Listen:AddGraphicsListenParam(txtgraphis3,{getvalues},extendparam) -- 添加自动刷新函数  extparam 扩展参数会传递到刷新函数里面

        end

UpdateGraphicsProgressById ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 按实例ID更新进度条图文的当前值/最大值
  • 具体使用案例如下:
lua
        local prograhics1 = Graphics:CreateGraphicsProgressByPos(  x, y + 1, z, Graphics:MakeGraphicsProgress(90, 100, [=[0xf44336]=], 1), nil, nil, worldId)

        local prograhics3 = Graphics:CreateGraphicsProgressByPos( x + 4, y + 1, z, Graphics:MakeGraphicsProgress(89, 100, [=[0xf44336]=], 1), nil, nil, worldId)

        if prograhics1 and prograhics3 then

            self:ThreadWait(1)

        end

        local updateResult1 = false

        local updateResult3 = false

        if prograhics1 and prograhics3 then

            updateResult1 = Graphics:UpdateGraphicsProgressById(prograhics1, 10, 200, false)

            updateResult3 = Graphics:UpdateGraphicsProgressById(prograhics3, 30, 40, true)

        end

        local prograhics2 = Graphics:CreateGraphicsProgressByPos(x - 4, y + 1, z, Graphics:MakeGraphicsProgress(10, 20, [=[0xf40000]=], 1, true),nil, nil, worldId)

        if prograhics2 then

            local extendparam = {1, 2, 3}

            local function getvalues()

                return math.random(1, 20), math.random(20, 40)

            end

            Listen:AddGraphicsListenParam(prograhics2, {getvalues}, extendparam)

        end

CreateGraphicsArrowByActorToPos ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 创建从生物指向位置的箭头
  • 具体使用案例如下:
lua
    local isSuccess = Graphics:CreateGraphicsArrowByActorToPos(playerId, Graphics:MakeGraphicsArrowToPos(x + 10, y, z, 1, [=[0xf44336]=], 1), {x = 0, y = 1, z = 0}, 20)

CreateGraphicsArrowByActorToActor ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 创建从生物指向生物的箭头
  • 具体使用案例如下:
lua
    local isSuccess = Graphics:CreateGraphicsArrowByActorToActor(playerId, Graphics:MakeGraphicsArrowToActor(playerId, 1, [=[0xf44336]=], 1), {x = 0, y = 1, z = 0}, 20)

CreateGraphicsArrowByPosToPos ​

  • 参数及类型:
    • pos:table 位置坐标{x,y,z}
    • info:table 图文信息
    • worldId:number 星球ID(可选)
  • 返回值及类型:
  • 该方法的其他说明: 创建从位置指向位置的箭头
  • 具体使用案例如下:
lua
        local isSuccess = Graphics:CreateGraphicsArrowByPosToPos({x = x, y = y + 3, z = z}, Graphics:MakeGraphicsArrowToPos(x + 10, y + 3, z, 1, [=[0xf44336]=], 1), worldId)

CreateGraphicsArrowByPosToActor ​

  • 参数及类型:
    • pos:table 位置坐标{x,y,z}
    • info:table 图文信息
    • worldId:number 星球ID(可选)
  • 返回值及类型:
  • 该方法的其他说明: 创建从位置指向生物的箭头
  • 具体使用案例如下:
lua
        local isSuccess = Graphics:CreateGraphicsArrowByPosToActor({x = x, y = y + 3, z = z}, Graphics:MakeGraphicsArrowToActor(playerId, 1, [=[0xf44336]=], 1), worldId)

CreateGraphicsLineByActorToPos ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 创建生物到位置的线
  • 具体使用案例如下:
lua
    local isSuccess = Graphics:CreateGraphicsLineByActorToPos(playerId, Graphics:MakeGraphicsLineToPos(x + 10, y, z, 1, [=[0xf44336]=], 1), {x = 0, y = 1, z = 0}, 20)

CreateGraphicsNavPathByActorToPos ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 创建生物到位置的寻路引导线
  • 具体使用案例如下:
lua
    local playerarr =  {playerId} --可见玩家列表

    local info = Graphics:MakeGraphicsNavPathToPos(x + 5, y, z, 1,playerarr)

    local result = Graphics:CreateGraphicsNavPathByActorToPos(playerId, info, {x = 1, y = 0, z = 0}, 1)

CreateGraphicsLineByActorToActor ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 创建生物到生物的线
  • 具体使用案例如下:
lua
    local isSuccess = Graphics:CreateGraphicsLineByActorToActor(playerId, Graphics:MakeGraphicsLineToActor(playerId, 1, [=[0xf44336]=], 1), {x = 0, y = 1, z = 0}, 500)

CreateGraphicsLineByPosToPos ​

  • 参数及类型:
    • pos:table 位置坐标{x,y,z}
    • info:table 图文信息
    • worldId:number 星球ID(可选)
  • 返回值及类型:
  • 该方法的其他说明: 创建位置到位置的线
  • 具体使用案例如下:
lua
        local isSuccess = Graphics:CreateGraphicsLineByPosToPos({x = x, y = y + 3, z = z}, Graphics:MakeGraphicsLineToPos(x + 10, y + 3, z, 1, [=[0xf44336]=], 1), worldId)

CreateGraphicsLineByPosToActor ​

  • 参数及类型:
    • pos:table 位置坐标{x,y,z}
    • info:table 图文信息
    • worldId:number 星球ID(可选)
  • 返回值及类型:
  • 该方法的其他说明: 创建位置到生物的线
  • 具体使用案例如下:
lua
        local isSuccess = Graphics:CreateGraphicsLineByPosToActor({x = x + 3, y = y, z = z}, Graphics:MakeGraphicsLineToActor(playerId, 1, [=[0xf44336]=], 1), worldId)

CreateGraphicsSurfaceByActorToPos ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 创建生物到位置的面
  • 具体使用案例如下:
lua
    local isSuccess = Graphics:CreateGraphicsSurfaceByActorToPos(playerId, Graphics:MakeGraphicsSurfaceToPos(x + 10, y, z, 1, [=[0xf44336]=], 1), {x = 0, y = 1, z = 0}, 20)

CreateGraphicsSurfaceByActorToActor ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 创建生物到生物的面
  • 具体使用案例如下:
lua
    local isSuccess = Graphics:CreateGraphicsSurfaceByActorToActor(playerId, Graphics:MakeGraphicsSurfaceToActor(playerId, 1, [=[0xf44336]=], 1), {x = -1, y = 0, z = 0}, 500)

CreateGraphicsSurfaceByPosToPos ​

  • 参数及类型:
    • pos:table 位置坐标{x,y,z}
    • info:table 图文信息
    • worldId:number 星球ID(可选)
  • 返回值及类型:
  • 该方法的其他说明: 创建位置到位置的面
  • 具体使用案例如下:
lua
        local isSuccess = Graphics:CreateGraphicsSurfaceByPosToPos({x = x, y = y + 3, z = z}, Graphics:MakeGraphicsSurfaceToPos(x + 10, y + 3, z, 1, [=[0xf44336]=], 1), worldId)

CreateGraphicsSurfaceByPosToActor ​

  • 参数及类型:
    • pos:table 位置坐标{x,y,z}
    • info:table 图文信息
    • worldId:number 星球ID(可选)
  • 返回值及类型:
  • 该方法的其他说明: 创建位置到生物的面
  • 具体使用案例如下:
lua
        local isSuccess = Graphics:CreateGraphicsSurfaceByPosToActor({x = x, y = y + 3, z = z}, Graphics:MakeGraphicsSurfaceToActor(playerId, 1, [=[0xf44336]=], 1), worldId)

ReplaceAllGraphics ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 将源对象上的所有图文信息迁移到目标对象
  • 具体使用案例如下:
lua
        local objs1 = GameObject:CreatePrefab(ObjType.Mob, 3402, x - 1, y, z, 1, true, worldId)

        if objs1 and #objs1 > 0 then

            objid1 = objs1[1]:GetId()

            Graphics:CreateGraphicsTxtByActor(objid1, Graphics:MakeGraphicsText([=[文本替换到嘟嘟鸟上面]=], 16, 0, 1, true), {x = 0, y = 1, z = 0}, 20)

        end

        self:ThreadWait(1.2)

        local objs2 = GameObject:CreatePrefab(ObjType.Mob, 3400, x + 1, y, z, 1, true, worldId)

        if objs2 and #objs2 > 0 then

            objid2 = objs2[1]:GetId()

        end

        local result = false

        if objid1 and objid2 then

            result = Graphics:ReplaceAllGraphics(objid1, objid2)

            print("result", result)

        end

CreateGraphicsImageByPos ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 在指定位置创建图像图文
  • 具体使用案例如下:
lua
        local isSuccess = Graphics:CreateGraphicsImageByPos(x, y + 3, z, Graphics:MakeGraphicsImage([=[0_10004]=], 1, 100, 1), nil, nil, worldId)

CreateGraphicsImageByActor ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 在生物上创建图像图文
  • 具体使用案例如下:
lua
    local isSuccess = Graphics:CreateGraphicsImageByActor(playerId, Graphics:MakeGraphicsImage([=[0_10004]=], 1, 100, 1), {x = 0, y = 1, z = 0}, 200)

GetInnerGraphicsOffset ​

  • 参数及类型:
  • 返回值及类型: 无返回值(结果通过callback回调)
  • 该方法的其他说明: 获取玩家昵称/称号的偏移高度并通过回调返回(玩家脚本调用)
  • 具体使用案例如下:
lua
    Graphics:GetInnerGraphicsOffset(playerId, PlayerNameType.Nick, function (height)

        if height == 0 then

            print("未展示")

        else

            print("高度", height)

        end

    end)

CreateBrushByPos ​

  • 参数及类型:
  • 返回值及类型:
    • id:number 笔刷实例ID;失败返回false
  • 该方法的其他说明: 在指定位置创建笔刷区域图文<1.54+>
  • 具体使用案例如下:
lua
        local pos = {x = x, y = y, z = z}

        local dim = {x = 3, y = 3, z = 3}

        local itype = 11 --类别ID不是枚举值

        local graphicsid = Graphics:CreateBrushByPos(pos, dim, 0xFF00ff, 0, itype, worldId)

RemoveGraphicsByGraphicsID ​

  • 参数及类型:
  • 返回值及类型:
  • 该方法的其他说明: 按图文实例ID删除图文信息
  • 具体使用案例如下:
lua
        result = Graphics:RemoveGraphicsByGraphicsID(graphicsId)