Giter Club home page Giter Club logo

Comments (3)

rezoner avatar rezoner commented on September 4, 2024

Hiya,

There is error in canvasquery.js code - it doesn't saves the context for
events other than mouse. I have fixed it in 0.9 version which I will post
in prerelease as soon as I get home.

I see you tried to workaround it by using this.tempContext so I am terribly
sorry that you had to go inside the library source.

if you are looking for a quick fix just replace (in canvasquery.js onResize
method)

var self = this;

with

var self = this.tempContext || this;

Will keep you informed,

Cheers from neighborhood Poland

2013/4/19 Andre Meyering [email protected]

Hello,
I am really new to CanvasQuery, so I hope this isn't such a stupid
question :)

(function (window, document, undefined) {
/* Example code */
var imagesData = window.imagesData;

var game = {
    player: {
        found: []
    },
    setup: function () {
        this.layer = cq().framework(this, this);
        this.layer.appendTo("body");
    },
    loadImage: function (callback) {
        var imageObj = new Image();
        imageObj.onload = function() {
            if (callback) {
                callback(imageObj);
            }
        };
        imageObj.src = imagesData[0].src;
    },
    createImage: function () {
        var self = this;
        this.loadImage(function (image) {
            self.layer.drawImage(image, 0, 0, self.layer.canvas.width, self.layer.canvas.height);
        });
    },
    onStep: function (delta) {
    },
    onRender: function () {
    },
    onResize: function (width, height) {
        /* resize canvas with window */
        this.canvas.width = width;
        this.canvas.height = height;

        /* Works first time. But not when resizing... I get: '...has no method 'createImage'' */
        this.tempContext.createImage();

    },

    onMouseUp: function (x, y) {
        console.log(x, y)
    }
};

game.setup();

}(window, document));

My problem is, that onResize() calls createImage() when initializing, but
not when resizing.
How do I call createImage() inside of onResize() correctly?

Greeting form Germany,
Andre

BTW: Huge thanks for CanvasQuery [image: 👍]


Reply to this email directly or view it on GitHubhttps://github.com//issues/16
.

Rezoner Sikorski
HTML5 Gamedeveloper
http://rezoner.net

from canvasquery.

rezoner avatar rezoner commented on September 4, 2024
  • if you fix it then just use

this.createImage

as this will mean your game object after that patch

2013/4/19 Przemys³aw Sikorski [email protected]

Hiya,

There is error in canvasquery.js code - it doesn't saves the context for
events other than mouse. I have fixed it in 0.9 version which I will post
in prerelease as soon as I get home.

I see you tried to workaround it by using this.tempContext so I am
terribly sorry that you had to go inside the library source.

if you are looking for a quick fix just replace (in canvasquery.js
onResize method)

var self = this;

with

var self = this.tempContext || this;

Will keep you informed,

Cheers from neighborhood Poland

2013/4/19 Andre Meyering [email protected]

Hello,
I am really new to CanvasQuery, so I hope this isn't such a stupid
question :)

(function (window, document, undefined) {
/* Example code */
var imagesData = window.imagesData;

var game = {
    player: {
        found: []
    },
    setup: function () {
        this.layer = cq().framework(this, this);
        this.layer.appendTo("body");
    },
    loadImage: function (callback) {
        var imageObj = new Image();
        imageObj.onload = function() {
            if (callback) {
                callback(imageObj);
            }
        };
        imageObj.src = imagesData[0].src;
    },
    createImage: function () {
        var self = this;
        this.loadImage(function (image) {
            self.layer.drawImage(image, 0, 0, self.layer.canvas.width, self.layer.canvas.height);
        });
    },
    onStep: function (delta) {
    },
    onRender: function () {
    },
    onResize: function (width, height) {
        /* resize canvas with window */
        this.canvas.width = width;
        this.canvas.height = height;

        /* Works first time. But not when resizing... I get: '...has no method 'createImage'' */
        this.tempContext.createImage();

    },

    onMouseUp: function (x, y) {
        console.log(x, y)
    }
};

game.setup();

}(window, document));

My problem is, that onResize() calls createImage() when initializing,
but not when resizing.
How do I call createImage() inside of onResize() correctly?

Greeting form Germany,
Andre

BTW: Huge thanks for CanvasQuery [image: 👍]

Reply to this email directly or view it on GitHubhttps://github.com//issues/16
.

Rezoner Sikorski
HTML5 Gamedeveloper
http://rezoner.net

Rezoner Sikorski
HTML5 Gamedeveloper
http://rezoner.net

from canvasquery.

bugwelle avatar bugwelle commented on September 4, 2024

Thanks for the fast answer :)
👍

from canvasquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.