Erik Oros wrote:
Hi there,
>
I’m not sure I’m completely following. The error is indicating that image hasn’t been created yet (i.e. that it is undefined.) Would you be able to share the code where you define image, for example:
[…]
>
As well as the code after that, up to the line that is causing the error:
[…]
Hi there,
@
var CircleSprite = cc.Sprite.extend({
*radians:0,
ctor:function {
this.*super();
},
draw:function () {
cc.renderContext.fillStyle = “rgba(255,255,255,1)”;
cc.renderContext.strokeStyle = “rgba(255,255,255,1)”;
if (this.*radians < 0)
this.*radians = 360;
cc.drawingUtil.drawCircle(cc.PointZero(), 30, cc.DEGREES_TO_RADIANS(this.*radians), 60, true);
},
myUpdate:function {
this.*radians = 6;
//this.*addDirtyRegionToDirector);
}
});
var Helloworld = cc.Layer.extend {
var selfPointer = this;
this.*super;
var size = cc.Director.getInstance.getWinSize;
this.map = new cc.TMXTiledMap.create;
this.setTouchEnabled;
this.adjustSizeForWindow;
window.addEventListener {
selfPointer.adjustSizeForWindow;
});
return true;
},
adjustSizeForWindow:function {
var margin = document.documentElement.clientWidth document.body.clientWidth;
if (document.documentElement.clientWidth < cc.originalCanvasSize.width) {
cc.canvas.width = cc.originalCanvasSize.width;
} else {
cc.canvas.width = document.documentElement.clientWidth - margin;
}
if (document.documentElement.clientHeight < cc.originalCanvasSize.height) {
cc.canvas.height = cc.originalCanvasSize.height;
} else {
cc.canvas.height = document.documentElement.clientHeight - margin;
}
var xScale = cc.canvas.width / cc.originalCanvasSize.width;
var yScale = cc.canvas.height / cc.originalCanvasSize.height;
if (xScale > yScale) {
xScale = yScale;
}
cc.canvas.width = cc.originalCanvasSize.width * xScale;
cc.canvas.height = cc.originalCanvasSize.height * xScale;
var parentDiv = document.getElementById(“Cocos2dGameContainer”);
if (parentDiv) {
parentDiv.style.width = cc.canvas.width + “px”;
parentDiv.style.height = cc.canvas.height + “px”;
}
cc.renderContext.translate(0, cc.canvas.height);
cc.renderContext.scale(xScale, xScale);
cc.Director.getInstance().setContentScaleFactor(xScale);
},
// a selector callback
menuCloseCallback:function (sender) {
cc.Director.getInstance().end();
},
onTouchesBegan:function (touches, event) {
this.isMouseDown = true;
},
onTouchesMoved:function (touches, event) {
if (this.isMouseDown) {
if (touches) {
//this.circle.setPosition(cc.p(touches[0].getLocation().x, touches[0].getLocation().y));
}
}
},
onTouchesEnded:function (touches, event) {
this.isMouseDown = false;
},
onTouchesCancelled:function (touches, event) {
console.log(“onTouchesCancelled”);
}
});
var HelloWorldScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new Helloworld();
layer.init();
//layer.charactersService();
//setInterval(layer.charactersService,200);
this.addChild(layer);
}
});
@
Mistakes here:“this.map = new cc.TMXTiledMap.create(”map/bg.tmx“);”