第9页:第六步代码制作(1)
展开第六步:代码制作
打开goldcoin\scripts\prefabs新建goldcoin和exchange的文本文档。
点击工具-文件夹选项-查看,去除勾选的隐藏已知文件类型的拓展名
然后把exchange和goldcoin的拓展名改为
双击打开goldcoin.lua写入
local assets=
{
Asset("ANIM", "anim/goldcoin.zip"),
Asset("ATLAS", "images/inventoryimages/goldcoin.xml"),
}
local function fn(Sim)
local inst = CreateEntity()
inst.entity:AddTransform()
inst.entity:AddAnimState()
inst.entity:AddSoundEmitter()
inst.entity:AddPhysics()
MakeInventoryPhysics(inst)
inst.AnimState:SetBank("goldcoin")
inst.AnimState:SetBuild("goldcoin")
inst.AnimState:PlayAnimation("idle")
inst:AddComponent("edible")
inst.components.edible.foodtype = "ELEMENTAL"
inst.components.edible.hungervalue = 2
inst:AddComponent("tradable")
inst:AddComponent("inspectable")
inst:AddComponent("stackable")
inst:AddComponent("inventoryitem")
inst.components.inventoryitem.atlasname = "images/inventoryimages/goldcoin.xml"
return inst
end
return Prefab( "common/inventory/goldcoin", fn, assets)
更多相关内容请关注:饥荒专区
责任编辑:修凡客
擦边的女生不怕家人看到吗?肉腿缺点是没有的囧图
《诡秘之主》游戏公开实机演示!场景细节效果逼真
12月PS+会免公布!地平线IP作品+砍丧尸爽游在内
超越巫师3同期!CDPR官宣《2077》销量破3500万份
又能看美女泡澡了!《仁王3》新截图:温泉将回归
50岁儿打死81岁妈的50岁男友 过玩偶姐姐人生的囧图