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

6 years ago by Ash_Blue

I need to draw a pre-rendered Canvas as an ig.AnimationSheet

this.animSheet = new ig.AnimationSheet(this.canvas, this.canvas.width, this.canvas.height);

Problem is ig.Image doesn't appear to accept Canvas images. I need the pivot and some other animation methods. Any ideas on the most efficient way to get this working?

I think something like this would fix the issue at hand but haven't tried it.

  load: function (loadCallback) {
    // If a canvas image hijack me and set the data, then ignore this.parent below

If this is that simple, any reason why ImpactJS's core can't support this? Only potential problem I could think of is it might cause issues with Ejecta.

6 years ago by Ash_Blue

Note, I know you can simply do a this.canvas.toDataURL(), but this doesn't seem like a good approach.

6 years ago by stillen

Can you do the canvas.toDataURL() and set that to an invisible image on the page, basically making a new image, then set that new image in the image load?

I did one of those dress up games, and had a lot of issues with loading images on the fly. I used this trick to export the image and save it on the server then reload it into the impact game, but maybe you can skip the server save issue.

Will the gameplay need this function or are you just making new animation sheets?

6 years ago by Joncom

Running with your idea of overloading ig.Image, so it can take a canvas instead of an image file path:

    init: function(input) {
        if(typeof input === 'string') { // If string path provided..
            return this.parent(input); // Load image normally.
        // Assume input is a canvas.
        this.loaded = true; = input;
        this.width = / ig.system.scale;
        this.height = / ig.system.scale;

5 years ago by Ash_Blue

I think that is perfect. Going to give it a try in the near future when I finish integrating ImpactJS with my NodeJS server.
Page 1 of 1
« first « previous next › last »