• Content Count

  • Joined

  • Last visited

  1. The result of the code below can be seen HERE function preload() { this.svbmd = game.add.bitmapData(400, 300, "slbmd"); this.svbmdAreas= []; var w = this.svbmd.width / 11; var h = this.svbmd.height / 6; for (var i = 0; i < 11; i++) { var areaCol = []; for (var j = 0; j < 6; j++) { areaCol.push(new Phaser.Rectangle(i * w, j * h, w, h)); } this.svbmdAreas.push(areaCol); } for (var k = 0; k < 11; k++) { var val = k / 10; for (var l = 0; l < 6; l++) { var sat = l / 5; var rect = this.svbmdAreas[k][l]; var col = Phaser.Color.HSVtoRGB(0.5, sat, val); this.svbmd.rect(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, Phaser.Color.RGBtoString(col.r, col.g, col.b, 255)); } } } function create() { this.svpicker = this.svbmd.addToWorld(200, 100); this.tooltip = game.make.bitmapData(64, 64); this.sprite = game.add.sprite(0, 0, this.tooltip); game.input.addMoveCallback(function (pointer, x, y) { if (x >= this.svpicker.x && x <= this.svpicker.x + this.svpicker.width && y >= this.svpicker.y && y <= this.svpicker.y + this.svpicker.height) { // for some reason color always seems to be the same, no matter which pixel is picked var color = this.svbmd.getPixelRGB(x - this.svpicker.x , y - this.svpicker.y); this.tooltip.fill(125, 125, 125); this.tooltip.rect(1, 1, 62, 62, color.rgba); this.sprite.x = x; this.sprite.y = y; }}, this); }
  2. I'm trying to create a HSV color picker using BitmapData. The implementation can be found in this Phaser Sandbox, I followed this example, with the notable difference, that I'm not using an image to generate the BitmapData but I'm generating the data myself. Unfortunately I seem to be unable to retrieve the color data for a given pixel (I tried BitmapData.getPixel(), getPixelRGB, getPixel32()). Does anyone have an idea what I'm doing wrong?
  3. Hi, I've encountered a strage problem while building a little, mostly static mobile game using Intels XDK, Cordova and Phaser (2.4.6). It's targeted at Android and uses the Crosswalk web runtime. I basically followed Matt McFarlands menu tutorial, and created States to do stuff like booting up, loading all assets, showing a splash screen, showing a menu, the levels etc. I'm using one Phaser.Graphics object per State to draw on (my game only needs a few geometric items). Additionaly I'm using the SaveCPU plugin to avoid unnecessary render cycles. Unfortunately removing it doesn't seem to remove the flashing problem. The stage.background is set to white, in the HTML part backgroud colors are also set to white. When moving from one State to the next I nevertheless get strange black flashes after entering the new State. Sometimes they cover the whole viewable area, sometimes they seem to be a black rectangle originating at the canvas center and covering only the lower right quadrant. I only get those flashes on mobile devices, they don't happen in a browser on a PC. I also observed that they seem to appear only after I add the Graphics object to a State, States whithout Graphics objects don't flash. Unfortunately I wasn't able to find out when exactly a flash occurs, but it seems to be either in or before/after init(), preload() or create(). The typical structure of my States looks like that: MyState = function () {} MyState.prototype = { init: function () { game.stage.backgroundColor = "#FFFFFF"; this.graphics = game.make.graphics(0, 0); // do some more stuff, initialise variables etc. }, preload: function () { this.graphics.alpha = 0; this.graphics.width = game.global.canvasWidth; this.graphics.height = game.global.canvasHeight; // do some more stuff }, create: function() { // do some more stuff game.add.existing(this.graphics); // do some more stuff, set up input handlers etc. // graphics fade in game.add.tween(this.graphics).to({alpha: 1}, 1000, Phaser.Easing.Quadratic.Out, true); // rendering was set to 60 FPS in the previous state (probably unnecessarily), // as long as there are active tweens forceRender() of the SaveCPU plugin is called in update() game.global.saveCpu.renderOnFPS = 0; }, update: function () { if (game.global.saveCpu.renderOnFPS === 0 && game.tweens.getAll().length > 0) game.global.saveCpu.forceRender(); }, render: function () { this.graphics.clear(); // draw stuff like menu buttons game pices etc using graphics drawing methods }, // [ ... more methods for state specific stuff ... ] moveToNextState: function (stateName) { // fade out the graphics and move on to the next state game.global.saveCpu.renderOnFPS = 60; var theEndTween = game.add.tween(this.graphics).to({alpha: 0}, 1000, Phaser.Easing.Quadratic.Out, true); theEndTween.onComplete.add(function () { game.state.start(stateName, true, false); }, this); } } So I wonder if anybody has an idea about what causes the flashes and how I may avoid them?
  4. I ran into a strange problem: when using phaser.min.js, onTap doesn't seem to fire. It works with phaser.js though. I'm using a very minimal example to test it: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create }); function create() { game.input.onTap.add(function onTap(pointer) { console.log("tap")} , this); } I'm using the developer tools in Firefox and Chrome to see what's written to the console. When using paser.js I get all "tap" message, when using phaser.min.js I get nothing. Is this a bug or am I missing someting?
  5. Hi, I've read quite a few posts on the forum but didn't really find an answer, so if it has been answered elsewhere I'd be happy to get a link. I'm currently trying to make a game using Intel XDK and Phaser (I'm new to both, though). The game will be pretty simple and mostly static, basically a board game on a mobile screen. I'm using the CANVAS renderer, and I'm drawing directly to the canvas (no sprites, no images, just drawing primitives). There are no issues with different screen sizes or aspect ratios, as the game scene is calculated to fit into any ratio and size. Phaser will basically only be used to handle the setup, level loading and stuff (yeah I guess I could ditch Phaser and make a pure canvas game, but Phaser seemed to make it easier to get into mobile development). I noticed that the canvas size is only half of the device size, which seems to result in blurry lines and jagged edges on my device (Nexus 5) and even in the emulator of XDK. Due to the game being static, I don't expect any performance issues with full HD resolution. So my questions are: Is there a way to set the full device resolution to the canvas? Is there a way to control render updates etc? I don't need 60 render cycles per seconds on a static scene with nothing moving, I'd prefer updating the scene on demand (after something actually changed). Thanks!