Francesca
Francesca

Reputation: 28148

EaselJS: Adding a static bitmap to a page with position (x,y)

I'm using EaselJS for the first time and am confused as to how to load a bitmap onto the canvas as specific co-ordinates.

First I'm defining my EaselJS stage:

var stage = new createjs.Stage("ad_canvas");

Then I'm defining a new bitmap:

var skyLogo = new createjs.Bitmap("http://francesca-designed.me/sky-test/logo.png");

I'm then creating the x & y coordinates I'd like to place this bitmap at, and adding it to the stage.

skyLogo.x = 56;
skyLogo.y = 115;
stage.addChild(skyLogo);

I just get a blank canvas and no errors. I'm new to this, and I don't know what I've missed.

Codepen

Upvotes: 2

Views: 1507

Answers (1)

Francesca
Francesca

Reputation: 28148

I worked out the solution. The Bitmap must be added to the stage first, and then the positioning can occur:

var skyLogo = new createjs.Bitmap("http://francesca-designed.me/sky-test/logo.png");
stage.addChild(skyLogo);
skyLogo.x = 20;
skyLogo.y = 208;
stage.update();

Upvotes: 1

Related Questions