I'm trying to create an animation by setting a background to a canvas and then trying to move my assets over the background image. I'm able to display the background image in the canvas and also able to preload all my assets. However, I'm not able to display any of the assets on the canvas.
I tried to play around with the coordinates of the bitmap I'm trying to display in case if it's displaying outside the visible area. I also tried to check if there is any problem with the timing of updating the stage, but no luck. Any help would be appreciated.
function set()
{
var cgroup = new createjs.Container();
cgroup.x = 100;
cgroup.y = 100;
// var path = 'img/cloud1.png';
var img = preload.getResult("c1");
console.log(img.src); //displaying correct preloaded file
var cloud1 = new createjs.Bitmap(img);
cgroup.addChild(cloud1);
cloud1.x = 120;
cloud1.y = 120;
cloud1.regX = 62;
cloud1.regY = 62;
stage.addChild(cgroup);
stage.update();
}
You need to call the function to make it run. For instance, this would be for when the page loads.
window.onload() = function(){
var cgroup = new createjs.Container();
cgroup.x = 100;
cgroup.y = 100;
// var path = 'img/cloud1.png';
var img = preload.getResult("c1");
console.log(img.src); //displaying correct preloaded file
var cloud1 = new createjs.Bitmap(img);
cgroup.addChild(cloud1);
cloud1.x = 120;
cloud1.y = 120;
cloud1.regX = 62;
cloud1.regY = 62;
stage.addChild(cgroup);
stage.update();
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With