상세 컨텐츠

본문 제목

How to define cocos creator constant variable?

개발생활/Cocos2d

by 한국인맛집 2021. 5. 4. 17:01

본문

반응형

 

This is the solution.

const CONSTANT_VAR = 10;
const CONSTANT_STRING = "StringValue";


var ContantClass = cc.Class( {
	extends: Component,
	
    properties:{
       number: 0,
       name: "",
    },
    
    GetConstantVar: function(){
    	return CONSTANT_VAR;
	}
    
    GetConstantString: function(){
		return CONSTANT_STRING;
	}
    
    
    foo: function(){
		console.log(this.GetConstantVar());
	}
    
    boo: function(){
		var value = CONSTANT_VAR;
        console.log(value);
        
	}
    
    poo: function(){
		console.log(this.GetConstantString());
	}
    
    coo: function(){
		console.log(CONSTANT_STRING);
	}
    

)};

 

반응형

관련글 더보기