Karzam

Members
  • Content Count

    4
  • Joined

  • Last visited

  1. That's working, I just find the damn error at the first line... My problem with Phaser is resolved, but I don't know why the hella canvas doesn't load images...
  2. Hi everyone, I'm tryin to draw a simple image with Phaser and I've a problem (the same I had yesterday with simple canvas html5) Images seems to failed when loading and so they don't appears, only on Chrome and not in Firefox which work perfectly. I have an error : Uncaught SecurityError: Failed to execute 'texImage2D' on 'WebGLRenderingContext': The cross-origin image at file:///C:/Users/Baptiste/Desktop/Pixel%20Tank/assets/wall.png may not be loaded.I tried to reinstall Chrome but it doesn't works and I'm coming crazy because yet I lost 2 days on that error. For my canvas problem yesterday it finally worked when I did a kind of preloader but I don't know why only on Chrome and not in Firefox, and I precise that I already used Canvas and I never had to do a preloader to draw an image... Here is my code (so works perfectly on Firefox but not even on Chrome) : var game = new Phaser.Game(800, 600, Phaser.AUTO, 'Pixel Tank', { preload: preload, create: create, update: update });// Préchargement des images function preload() { game.load.image('sand', 'assets/wall.png');}// Initialisationfunction create() { game.add.sprite(0, 0, 'sand');}// Boucle de jeufunction update() {}Thanks for help !
  3. Hi everyone, I'm coding a project and I've got a problem when I try getting keyboard input in a dedicated class. So this is my Controller class : Controller = function() { // Initialisation clavier document.onkeydown = this.onKeyDown; document.onkeyup = this.onKeyUp; // Touches this.left = false; this.up = false; this.down = false; this.right = false;}// Touche appuyée Controller.prototype.onKeyDown = function(event) { if (event.keyCode == 37) { this.left = true; } if (event.keyCode == 38) { this.up = true; } if (event.keyCode == 39) { this.down = true; } if (event.keyCode == 40) { this.right = true; }}// Touche relâchée Controller.prototype.onKeyUp = function(event) { if (event.keyCode == 37) { this.left = false; } if (event.keyCode == 38) { this.up = false; } if (event.keyCode == 39) { this.down = false; } if (event.keyCode == 40) { this.right = false; }}... with which I create an occurence during initialization. But when I try to get boolean state in an other class : // DéplacementPlayer.prototype.move = function() { if (controler.left) { this.posHorizontal -= this.speed; }}this isn't working ! When I display the state in the controller class it return 'true' but not in another classes. I'v got no error but only a 'false' displayed (i've tried with console.log but no way). Thanks for help !
  4. Hi everybody I'm trying to call a refresh class method from objects in a Phaser group. This method must call other methods which have to be update in the game loop, but I can't call it. I just tried to do it with the forEach method and also with a simple for loop, but it doesn't work and I got an "Uncaught TypeError: undefined is not a function". So I tried with bind() without success, because I don't understand how to call a class method from such a function. Thanks for your help and please escuse my hella english, I'm french. // Rafraîchissementfunction update() { // Tank tank1.update(); // Bombes bombs.forEach(function(item) { item.refresh(); });} The other thing I tried with the same error : // Rafraîchissementfunction update() { // Tank tank1.update(); // Bombes for (var i = 0; i < bombs.length; i++) { bombs.getAt(i).refresh(); }}