ashtrail

Members
  • Content Count

    7
  • Joined

  • Last visited

  1. I think so. So based on Tom Atom's example "atlasFrameName" would be "Spritor"? And that will take the specific area of the image for the sprite, or am I wrong?
  2. Hello, I've got a strange error. I've got a quitting menu in my game which basically ask you if you want to quit or not when you click on a button (that part works fine). If ever you answer "Nope" then I will destroy without any mercy all sprites that were used to buld the quit menu (that part kinda works but wait for it...). Problem is if you can't set your mind and you click that quitting button once again, and decide to say no a second time (why would you even do that I don't know but...) and at that point no sprites are destroyed (none, not even one) but the game unpause for the rest of it and there's menu bits in the game (great T_T). Also it throws an error at the 8th element (it doesn't destroy any of the first seven ones though) which is : "Uncaught TypeError: Cannot read property 'parentNode' of null". I've tried real hard to understand this but I don't. Why the hell does it works once and not twice? Here's some code : Quit Menu code : quitButton = game.add.sprite(SIZE_X * 0.03, SIZE_Y * 0.03, 'quit'); quitButton.inputEnabled = true; quitButton.events.onInputUp.add(function () { var darkScreen; var exitButton, exitButtonText, exitButtonHitBox; var unpauseButton, unpauseButtonText, unpauseButtonHitBox; var showQuitMessage; var quitTitleSprite, quitMessageSprite; // Pause game pauseGame(game, gameBoard); miniature.inputEnabled = false; quitButton.inputEnabled = false; onMenu2 = true; // prevents the miniature and the quit button from poping on top of the darkened screen // darken screen (black transparent sprite of the size of the screen) darkScreen = game.add.graphics(0, 0); darkScreen.beginFill(0x000000, 1); darkScreen.alpha = 0.5; darkScreen.drawRect(0, 0, SIZE_X, SIZE_Y); // White box showQuitMessage = game.add.graphics(0, 0); showQuitMessage.beginFill(0xFFFFFF, 1); showQuitMessage.drawRect(SIZE_X * 0.2, SIZE_Y * 0.15, SIZE_X * 0.6, SIZE_Y * 0.7); // Text output quitTitleSprite = game.add.text(SIZE_X * 0.4, SIZE_Y * 0.3, quitTitle, {font: 'bold ' + Math.floor(SIZE_Y / 15) + 'pt Arial', fill : '#000'}); quitMessageSprite = game.add.text(SIZE_X * 0.325, SIZE_Y * 0.45, quitMessage, {font: Math.floor(SIZE_Y / 30) + 'pt Arial', fill : '#000'}); // exitButton && unpauseButton graphics exitButton = game.add.graphics(0, 0); exitButton.beginFill(0x81DEED, 1); exitButton.drawRect(SIZE_X * 0.35, SIZE_Y * 0.65, SIZE_X * 0.1, SIZE_Y * 0.06); exitButtonText = game.add.text(SIZE_X * 0.38, SIZE_Y * 0.665, quitButton1Text, {font: Math.floor(SIZE_Y / 40) + 'pt Arial', fill : '#000'}); unpauseButton = game.add.graphics(0, 0); unpauseButton.beginFill(0x81DEED, 1); unpauseButton.drawRect(SIZE_X * 0.55, SIZE_Y * 0.65, SIZE_X * 0.1, SIZE_Y * 0.06); unpauseButtonText = game.add.text(SIZE_X * 0.58, SIZE_Y * 0.665, quitButton2Text, {font: Math.floor(SIZE_Y / 40) + 'pt Arial', fill : '#000'}); // exitButton && unpauseButton clicking gestion unpauseButtonHitBox = new Phaser.Rectangle(SIZE_X * 0.55, SIZE_Y * 0.65, SIZE_X * 0.1, SIZE_Y * 0.06); exitButtonHitBox = new Phaser.Rectangle(SIZE_X * 0.35, SIZE_Y * 0.65, SIZE_X * 0.1, SIZE_Y * 0.06); game.input.onDown.add(function(pointer) { if (onMenu2) { if (unpauseButtonHitBox.contains(pointer.x, pointer.y)) { unpauseGame(game, gameBoard, 2, showQuitMessage, unpauseButton, exitButton, darkScreen, quitTitleSprite, quitMessageSprite, unpauseButtonText, exitButtonText); miniature.inputEnabled = true; quitButton.inputEnabled = true; } else if (exitButtonHitBox.contains(pointer.x, pointer.y)) location.reload(true); } }); });Pausing function : function pauseGame(game, gameBoard) { for (var i = 0; i < NB_CELL_Y; i++) { for (var j = 0; j < NB_CELL_X; j++) { gameBoard.puzzle[i][j].sprite.inputEnabled = false; } } }Quitting the quitting menu code (or unpause function) : // After the menu argument, all args must be sprites and they will all be destroyed function unpauseGame(game, gameBoard, menu) { var i; if (menu == 1) // full picture Menu onMenu = false; // useful for stopping some sprite events, and starting others else if (menu == 2) // exit Menu onMenu2 = false; // Allows the sprites to be moved again if (onMenu == false) // the game can't go back to it's normal behavior if we're still on the full picture menu { for (i = 0; i < NB_CELL_Y; i++) { for (var j = 0; j < NB_CELL_X; j++) { gameBoard.puzzle[i][j].sprite.inputEnabled = true; } } } // deletes the sprites that made the menu for (i = 3; i < arguments.length; i++) { console.log("arg["+i+"] destroyed."); arguments[i].destroy(); } }Here's the console log : inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startpuzzle_plus.js:316 arg[3] destroyed.puzzle_plus.js:316 arg[4] destroyed.puzzle_plus.js:316 arg[5] destroyed.puzzle_plus.js:316 arg[6] destroyed.puzzle_plus.js:316 arg[7] destroyed.puzzle_plus.js:316 arg[8] destroyed.puzzle_plus.js:316 arg[9] destroyed.puzzle_plus.js:316 arg[10] destroyed.phaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled false d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: true, priorityID: 0, useHandCursor: false…}phaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}_dragPoint: d.Point_pointerData: Array[10]_tempPoint: d.PointallowHorizontalDrag: trueallowVerticalDrag: trueboundsRect: nullboundsSprite: nullbringToTop: falseconsumePointerEvent: falsedragFromCenter: falsedragOffset: d.Pointdraggable: trueenabled: truegame: d.GameisDragged: falsenext: d.InputHandlerpixelPerfect: falsepixelPerfectAlpha: 255prev: d.InputHandlerpriorityID: 0snapOffset: d.PointsnapOnDrag: falsesnapOnRelease: falsesnapX: 0snapY: 0sprite: d.SpriteuseHandCursor: false__proto__: Objectphaser.min.js:6 InputHandler startphaser.min.js:7 inputEnabled true d.InputHandler {sprite: d.Sprite, game: d.Game, enabled: false, priorityID: 0, useHandCursor: false…}phaser.min.js:6 InputHandler startpuzzle_plus.js:316 arg[3] destroyed.puzzle_plus.js:316 arg[4] destroyed.puzzle_plus.js:316 arg[5] destroyed.puzzle_plus.js:316 arg[6] destroyed.puzzle_plus.js:316 arg[7] destroyed.phaser.min.js:7 Uncaught TypeError: Cannot read property 'parentNode' of nullActually I'm talking of sprite but there's some text and graphics too, but since it works the first time I guess ."destroy()" works on them too. If you neef any more info I'll be glad to give it, sorry if I'm not very precise and for the high number of lines of code. Thanks in advance! Stupid PS : Is it me or does Syntax Highlighting in the code balise has a serious problem (or more precisly is inexistant).
  3. But will that make it a Phaser.Sprite object? Cuz I want a Phaser.Sprite so I can use Sprite methods... (that's the problem in fact T_T). Is it a way to load only a part of the image and then assign it to a Sprite? Or does it create a new object called Spritor? (I don't use json yet, I'm still on the localhost phase, using real images that are in files, so I apologize for my lack of knowledge in that field)
  4. You think it's because of the "this"? I'll try it out next time I want to make a clickable rectangle. For that rectangle I found another way to do it ( http://www.html5gamedevs.com/topic/5685-clickable-area/ ). But thanks!
  5. Hi, for the project I'm doing I need to deal with imperfect spritesheet (and I can't modify them myself, my code needs to do this, and I'm using phaser and it's sprites). So I was wondering is there some kind of function that goes like that : mySuperSprite = new Phaser.Sprite(game, coord_x_in_img, coord_y_in_img, sprite_width, sprite_height, img);Where the point P(coord_x_in_img, coord_y_in_img) is the upper left corner of the sprite you want to create. With this you could for example make a sprite that's a nose, from a picture with a face on it. It would be really cool if it existed... Thanks in advance for your answers!
  6. Hello everyone, I'm trying to make a rectangle clickable just like a sprite. I read here and there and the hitArea way should be the best for me since the rectangle have variable size, so I can't really use an invisible sprite. That's what my code looks like but it raises the error : "Uncaught TypeError: Cannot read property 'onInputUp' of undefined". So what would be the proper way to do this (I coulnd't find doc on hitArea) : unpauseButton = game.add.graphics(0, 0);unpauseButton.beginFill(0x81DEED, 1);unpauseButton.drawRect(SIZE_X * 0.55, SIZE_Y * 0.65, SIZE_X * 0.1, SIZE_Y * 0.06);unpauseButton.hitArea = new Phaser.Rectangle(SIZE_X * 0.55, SIZE_Y * 0.65, SIZE_X * 0.1, SIZE_Y * 0.06);unpauseButtonText = game.add.text(SIZE_X * 0.55, SIZE_Y * 0.65, quitButton2Text, {fontSize: '16px', fill : '#000'});unpauseButton.hitArea.inputEnabled = true;// Error here :unpauseButton.hitArea.events.onInputUp.add(function () {unpauseGame(game, gameBoard, showQuitMessage, unpauseButton, darkScreen, quitTitleSprite, quitMessageSprite)});Thanks!