Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by KPDwyer

Hey guys,

I just spent some time figuring out a way to use images in my loading screen. My result looks something like this:

in main.js:

ig.global.LoadImage = new Image();
ig.global.LoadImage.src = "media/IAmAnImage.png"
ig.global.LoadImage.onload = function(){
     ig.main('#canvas', MyGame, 60, 
     ig.ua.viewport.width/2, ig.ua.viewport.height/2, 2, ig.ImpactSplashLoader);
}

and then in my customer loader class' draw method (impact-splash-loader.js) I used

ig.system.context.drawImage(ig.global.LoadImage,100,100);

Now, I recognize this is not as optimal as using the paths and curves like the impact custom loader. I also realize I'm effectively waiting for my loading screen to load so I can load the game (silly). but if its a small image and I barely notice the time, is this going to affect my game in any other negative manner?

1 decade ago by vincentpiel

I'd rather "inject" ig.loader to have it display some not-too hugly graphics while the image is loading, and display the image when it's here. Because after all, it's about playing a game, not watching a picture :-)
So yes, override the draw() method of the loader,and have a flag report the image loading state that you will use to draw or not the image. Watch out for the cases where 1) the image wouldn't load and 2) the image loaded after the game starts.

1 decade ago by AliJaffar

You can also use the following link to convert a png to canvas: http://lab.abhinayrathore.com/img2canvas/
Page 1 of 1
« first « previous next › last »