Stephen Persson

Members
  • Content Count

    12
  • Joined

  • Last visited

About Stephen Persson

  • Rank
    Member

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

685 profile views
  1. It works, but I tried on a 640x480 image and it was prohibitively slow until it crashed. This is what I did: var image = [[[0, 0, 0], [0, 0, 0], [255, 255, 255], ..., [255, 255, 255], [255, 255, 255], [255, 255, 255]]];var bmd = game.make.bitmapData(game.width, game.height);for (var x = 0; x < image.length; x++) { for (var y = 0; y < image[x].length; y++) { bmd.setPixel(x, y, image[y][x][0], image[y][x][1], image[y][x][2]); }}bmd.addToWorld();setPixel uses putImageData. Is this ok?
  2. What's the right way to draw an image pixel by pixel with bitmapdata? Assuming I'm getting the data from a matrix. var image = [['rgb( 0, 0, 0)', 'rgb( 0, 0, 0)', 'rgb(255,255,255)', 'rgb( 0, 0, 0)', 'rgb( 0, 0, 0)'], ['rgb( 0, 0, 0)', 'rgb( 0, 0, 0)', 'rgb(255,255,255)', 'rgb( 0, 0, 0)', 'rgb( 0, 0, 0)'], ['rgb( 0, 0, 0)', 'rgb(255,255,255)', 'rgb(255,255,255)', 'rgb(255,255,255)', 'rgb( 0, 0, 0)'], ['rgb( 0, 0, 0)', 'rgb(255,255,255)', 'rgb(255,255,255)', 'rgb(255,255,255)', 'rgb( 0, 0, 0)'], ['rgb(255,255,255)', 'rgb(255,255,255)', 'rgb(255,255,255)', 'rgb(255,255,255)', 'rgb(255,255,255)']];var bmd = game.make.bitmapData(game.width, game.height);for (var x = 0; x < image.length; x++) { for (var y = 0; y < image[x].length; y++) { bmd.?????????? }}bmd.addToWorld();
  3. I'm using Phaser 2.3.0 and I want to know the bounds of a rotated sprite. But when I change sprite.rotation, the values of sprite.getBounds() don't change: var sprite = game.add.sprite(0, 0, "sprite"); // game.load.spritesheet("sprite", "spritesheet.png", 32, 32);console.log(sprite.getBounds()); // Object { x: 0, y: 0, width: 32, height: 32, type: 22 }sprite.rotation = 0.52; // 30┬░console.log(sprite.getBounds()); // Object { x: 0, y: 0, width: 32, height: 32, type: 22 }What's wrong?How can I get the correct bounds?
  4. Stephen Persson

    ..

    .
  5. It seems "real" was too vague. I don't want original data, I want the data from the visual result, after the changes. I edited that word and moved my explanation to the first post.
  6. When you rotate the sprite, getBounds()'s x/y/width/height don't change.
  7. I didn't find out how to skew a sprite, do you have an example? But negative scaling will screw it.
  8. I'd like to get the visual x/y/width/height of a sprite after scaling/skewing/rotating/anchoring it. Can I do that with Phaser? The case: If you flip horizontally a sprite that has {x: 100, y: 100, width: 64, height: 64}, what will your eyes see on the screen? {x: 36, y: 100, width: 64, height: 64}. That's what I'm looking for. However, Phaser tells you:{x: 100, y: 100, width: -64, height: 64}. No big deal, you just do a little math to fix it, kinda like you showed there. That is, if you only scale it. It gets more mathematical when you also change the anchor, and turns into a geometric nightmare if you rotate it too. Phaser is heavily based on Flixel, right? Then my hopes are that you could do it like in Flash, where you can solve all of this by wrapping your sprite into a movieclip and getting the container's x/y/width/height.
  9. That's a more logical approach than setting an higher index. Thank you for your consideration, Xeke.
  10. I want a sprite always in the front. Setting z to max didn't do it. What is needed?