Adel

Members
  • Content count

    18
  • Joined

  • Last visited

About Adel

  • Rank
    Member

Contact Methods

  • Twitter
    https://twitter.com/II_Adel_II

Recent Profile Visitors

180 profile views
  1. Adel

    Easier way to load tiles (or images) in levels?

    Try to use inkscape to build the scene, then put inkscape coordinates in the json file.
  2. Adel

    How to extend state

    Phaser.State State = function () { Phaser.State.call(this); }; State.prototype = Object.create(Phaser.State.prototype); /** @type {State} */ State.prototype.constructor = State; State.prototype.init = function () { }; State.prototype.preload = function () { }; State.prototype.create = function () { }; /****************************************************************/ window.onload = function () { const game = new Phaser.Game(360, 640, Phaser.AUTO); game.state.add('State', new State()); game.state.start('State', true, false); }; /*********************************************************************/ // es2015 class State extends Phaser.State { constructor() { super(); } init() { } preload() { } create() { } } export { State };
  3. Adel

    Phaser 2.10 game responsive

    Try testing various settings, or maybe someone with more phaser experience will answer.
  4. Adel

    Phaser 2.10 game responsive

    What is the screen size of the device you tested, try this mini game on a mobile browser on portrait mode [only tested on chrome], and click on the full screen button, it uses SHOW_ALL scaling.
  5. Adel

    Phaser 2.10 game responsive

    I meant a background image to the html document, and when the canvas is centered, if it doesn't fill all the document part of the image will be visible.
  6. Adel

    Phaser 2.10 game responsive

    This ScaleManager guide is worth reading.
  7. Adel

    Phaser 2.10 game responsive

    Try setting a background image to the document, after it scales part of the images will show instead of the white borders. Setting a 16by9 resolution scale well on most of the mobile devices using SHOW_ALL.
  8. Adel

    Phaser 2.10 game responsive

    Have tried SHOW_ALL scaling mode this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.setMinMax(this.game.width / 2, this.game.height / 2, this.game.width * 2, this.game.width * 2); this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true;
  9. Have you tried to get a reference to `pointer.interactiveCandidates` on an onDown signal then in the update hook check if `input.activePointer.isDown` and interactiveCandidates[0] is the button you clicked
  10. Adel

    Help with Buttons

    Check Phaser.GameObjectFactory .button method
  11. Adel

    Help with new level (Newbie)

    /** * GameState * @constructor */ App.Game = function () { 'use strict'; Phaser.State.call(this); this.__player = {}; }; /** @type {Phaser.State} */ App.Game.prototype = Object.create(Phaser.State.prototype); /** @type {App.Game|*} */ App.Game.prototype.constructor = App.Game; Once a state is instantiated, all properties declared in the state constructor persists after restarting it. Same if those properties are declared in the global scope, global means they are properties of the window object.
  12. Adel

    Any Pause Screen Code / Examples?

    And here the methods to pause the game and display the pause menu App.Game.prototype.__togglePause = function () { 'use strict'; this.game.paused = !this.game.paused; }; App.Game.prototype.__togglePauseMenu = function () { 'use strict'; this.__groups['PauseMenu'].forEach(function (pauseElement) { if (pauseElement.__name !== 'GUI:PauseBtn') { pauseElement.visible = !pauseElement.visible; } }, this); };
  13. Adel

    Any Pause Screen Code / Examples?

    When the game is paused you can update the game objects in the .pauseUpdate loop. What I did here is initializing a property onPauseInput to null in the State constructor, when the game is paused, that property will hold a reference to Phaser.Signal, input.onUp. The callback function will have a pointer param, I check the pointer x and y agains the buttons bounds, if pointer.x and pointer.y are in bound that mean the button was clicked. In the resumed hook, the onPauseInput is detached then nullified. App.Game.prototype.pauseUpdate = function () { 'use strict'; if (!this.__onPauseInput) { this.__onPauseInput = this.input.onUp.add(function (pointer) { let x = pointer.position.x; let y = pointer.position.y; let btnBounds = {}; let clickedBtn = null; this.__groups['PauseMenu'].forEach(function (pauseElement) { if (pauseElement.__name !== 'Play:PausePanel') { btnBounds[pauseElement.__name] = pauseElement.getBounds(); } }, this); Object.keys(btnBounds).forEach(function (key) { let btn = btnBounds[key]; if ( x >= btn.x && x <= (btn.x + btn.width) && y >= btn.y && y <= (btn.y + btn.height) ) { clickedBtn = key; } }, this); switch (clickedBtn) { case 'GUI:PauseBtn': this.__togglePause(); break; case 'GUI:BackBtn': this.__togglePause(); break; case 'GUI:FullscreenBtn': this.__toggleFullScreen(); break; case 'GUI:MuteBtn': this.__togglePause(); this.__toggleMute(); break; case 'GUI:HomeBtn': this.__togglePause(); this.__SwitchScreen('Start', false); break; default: } }, this); } }; App.Game.prototype.resumed = function () { 'use strict'; if (this.__onPauseInput) { this.__onPauseInput.detach(); this.__onPauseInput = null; } };
  14. I encountered the same behavior using onDown, replaced it with onUp or onTap and it worked
  15. Adel

    In-game loading bar

    Hi, You can watch the loading progress using setPreloadSprite and onFileComplete signal from Phaser.Loader. If you want to watch the files loading progress before the page onload event try pace or nprogress.