大家好,我对typescript方面真的很不熟,想创一个Class里面放我的资料好使用
可是重整后却一直失败,能否帮我看看哪里出了问题
下面给些我写的资料
改成类似这样即可:
@property({
type: cc.Enum(test)
})
myEnum = test.ONE
感谢回复,请问能写的完整些吗?我有对你的方式在不同地方进行修改(newclass内,或者改class内部的命名方式)myEnum 后面是"等于"来着…?
但还是一样ctrl + R都会变回null要重新创建(话说进网页时是可以读取到上次修改的内容的)但看inspector时就跟我第一页的第二张图一样是null testclass
是能够生效的,你修改之后,点击 create 按钮试试。
var test = cc.Enum({
ONE: 1,
TWO: 2
});
const {ccclass, property} = cc._decorator;
@ccclass
export default class NewClass extends cc.Component {
@property({
type: cc.Mask
})
myMask: cc.Mask = null;
@property({
type: cc.Enum(test)
})
myEnum = test.ONE
@property({
displayName: "刮卡路径大小",
min: 32
})
size: number = 32;
}

我想做的是一个class 里面包含enum,float 就像是角色Data一样 然后我可以有很多的角色data
也就是把这个class变成array,如果只是显示enum本身的话目前是可以的
解决了 感谢
export enum RollerMgrState {
any = 0, A, ten,Nine,Diamands,J,K,Wild,FreeSpin,Hearts,Q,Skatter,Bonus
}
const {ccclass, property} = cc._decorator;
@ccclass(“TestClass”)
export class TestClass{
@property({type : cc.Enum(RollerMgrState)})
public Row1 : cc.Enum = RollerMgrState.any;
@property({type : cc.Enum(RollerMgrState)})
public Row2 : cc.Enum = RollerMgrState.any;
@property({type : cc.Enum(RollerMgrState)})
publicRow3 : cc.Enum = RollerMgrState.any;
@property({type : cc.Enum(RollerMgrState)})
public Row4 : cc.Enum = RollerMgrState.any;
@property({type : cc.Enum(RollerMgrState)})
public Row5 : cc.Enum = RollerMgrState.any;
@property({type : cc.Float})
pay : number = 5;
@property({type : cc.Float})
FreeSpins : number = 0;
@property({type : cc.Float})
PayMULT : number = 0;
// @property({type : cc.Boolean})
// This : Boolean = false;
}
@ccclass
export default class NewClass extends cc.Component {
@property({
type: TestClass
})
myEnum : TestClass;
@property({type : cc.Float})
pay : number = 5;
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
}
}
最重要的是@ccclass后要serialize,typescript的方式就是括号内加名称