Comments (3)
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,
AndreBTW: 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.
- 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,
AndreBTW: 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.
Thanks for the fast answer :)
from canvasquery.
Related Issues (20)
- Are colors broken right now? HOT 2
- Demos or tutorials? HOT 1
- Version 0.9.1 HOT 1
- drawSprite missing HOT 1
- text size HOT 1
- Logitech Universal Reciever is incorrectly recognised as a gamepad HOT 1
- Old browsers compatibility requestAnimationFrame HOT 2
- preventContextMenu not working HOT 1
- Sprites in Playground HOT 15
- Align HOT 8
- drawAtlasFrame() does not use x,y HOT 1
- Touchend is unreliable in multitouch HOT 4
- Integrating Playground with THREE.js
- Plugins in Playground HOT 1
- Mouselock Movement-Delta unprecise and IExplorer incompatible
- npm and browserify support HOT 14
- playground.Keyboard.prototype.keypress Event is an empty Function. HOT 7
- swapping color palettes
- cq.loadImages can not to use!
- Flip Sprite HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from canvasquery.