저는 cocos2d 코드를 작성하고 res 폴더에 정의 된 첫 번째 장면을 실행하고 ontouch 이벤트를 수행해야합니다. 코드를 작성했지만 "g_resources "오류가 발생하는 파일 : 나는 모든 내 이미지를 저장했다g_resources가 cocos2d에 정의되지 않았습니다
"use strict";
var cocos2dApp = cc.Application.extend({
config : document.ccConfig,
ctor : function(scene) {
this._super();
this.startScene = scene;
cc.COCOS2D_DEBUG = this.config['COCOS2D_DEBUG'];
cc.setup(this.config['tag']);
cc.AppController.shareAppController().didFinishLaunchingWithOptions();
},
applicationDidFinishLaunching : function() {
var that = this;
// initialize director
var director = cc.Director.getInstance();
var resourceSize = cc.size(1024, 768);
var designSize = cc.size(1024, 768);
var policy = new cc.ResolutionPolicy(cc.ContainerStrategy.PROPORTION_TO_FRAME, cc.ContentStrategy.NO_BORDER);
cc.EGLView.getInstance().setDesignResolutionSize(designSize.width,designSize.height,policy);
cc.EGLView.getInstance().resizeWithBrowserSize(true);
// director.setContentScaleFactor(2,2)
// enable High Resource Mode(2x, such as iphone4) and maintains low
// resource on other devices.
// director->enableRetinaDisplay(true);
// cc.setScaleX(0.5)
// cc.setScaleY(0.5)
// this.scale(0.5,0.5)
// turn on display FPS
director.setDisplayStats(this.config['showFPS']);
// set FPS. the default value is 1.0/60 if you don't call this
director.setAnimationInterval(1.0/this.config['frameRate']);
// create a scene. it's an autorelease object
// load resources and run
cc.LoaderScene.preload(g_resources, function() {
var startSceneInstance = new that.startScene();
director.replaceScene(startSceneInstance);
});
return true;
}
});
var myApp = new cocos2dApp(helloworldScene);
"main.js "다음
내의 코드"정의 resource.js "과 변수 이름은 g_resources과 동일 . 나는이 오류를주는 이유를 모른다. 누구나 나를 도와 줄 수있다.
g_resources가 정의되어 있지 않으면 정의해야 함을 의미합니다. 나는 자바 스크립트에 대해 많이 모르지만 var g_resources 행을 추가해야하는 것처럼 보입니다. – LearnCocos2D
정말 고마워요. – user3932077