Appolos

Members
  • Content Count

    9
  • Joined

  • Last visited

  1. Appolos

    Phaser Graphic

    Hello ! I need to create a block in center of screen with text. How to set this block and text set to center of screen ?? My code: this.graphics = this.add.graphics(0, 0); // this.graphics.pivot.set(0.5,0.5) this.menuText = this.add.text(0, 0, text, textStyle); this.graphics.beginFill(0xf9cb9c); this.graphics.drawRect( this.game.world.centerX / 2, this.game.world.centerY / 2, this.game.world.width / 2, this.game.world.height / 2 ); this.menuText.setTextBounds( this.game.world.centerX / 2, this.game.world.centerY / 2, this.game.world.width / 2, this.game.world.height / 2 ); this.shareText.setTextBounds( this.game.world.centerX / 2, this.game.world.centerY / 2 + 100, this.game.world.width / 2, this.game.world.height / 2 ); this.restartGame.setTextBounds( this.game.world.centerX / 2, this.game.world.centerY / 2 + 120, this.game.world.width / 2, this.game.world.height / 2 ); this.graphics.addChild(this.shareText); this.graphics.addChild(this.restartGame); this.graphics.addChild(this.menuText);
  2. have game on Phaser 2, I start integrate it in Facebook. And have some problem with function that allow user to share with friends. 1)Here example of code: let msg = 'Try this game' FBInstant.shareAsync({ intent: "REQUEST", image:user.playerPic, text: "Hey I'm stuck on this target! Can you help me?", data: {myReplayData:msg} }).then(() => { console.log("Success share"); this.resumeGame = true; this.checkStatusContinue(); }); 2) Here my error: POST https://m.facebook.com/games/quicksilver/share_score/ 500 ErrorUtils caught an error: "Cannot read property 'message' of null". Subsequent errors won't be logged; see https://fburl.com/debugjs. Please help with it. Thanks.
  3. Appolos

    Help with Data in Game

    Hello everyone ! I am new in Phaser, and I have some simple game on Phaser 2. And problem in what I have in game the target with some health, and the game end`s when targets health equal to zero, but then i go back to main menu and when I again go to game state the targets health already equal to zero. 1) Targets settings: class Target { constructor(health, viewPath) { this.health = health; this.viewPath = viewPath; } hit() { this.health -= 5; } } // creating Targets let wooden = new Target(10, "assets/targ.png"); let bear = new Target(20, "assets/targ1.png"); let celts = new Target(30, "assets/targ2.png"); let north = new Target(40, "assets/target3.jpg"); export const targets = { wooden:wooden, bear:bear, celts:celts, north:north }; 2) Game Preload: preload() { // Array of targets this.enemyGroup = [ targets.wooden, targets.bear, targets.celts, targets.north ]; this.enemy = null; this.levelGroup; this.levelData; // Set Level Settings this.levelGroup = [level.level1, level.level2, level.level3, level.level4]; this.levelData = this.levelGroup[+currentLevel]; // Get the current enemy this.enemy = Object.assign( this.enemyGroup[enemyCounter < 4 ? enemyCounter : 0] ); // loading assets this.load.image("target", this.enemy.viewPath); this.load.image( "weapon", UserWeapon.knife !== undefined ? UserWeapon.knife : "../../assets/knife3.png" ); this.load.spritesheet("coin", coin, 70, 96); } How to correctly save data between states and update data. Can you help with this problem, please!!)
  4. Appolos

    Phaser Tween positions

    Hello ! I have to variants - Phaser 3 and Phaser 2 tween creation I try to rewrite from 3d version to 2nd versions. Here, that I created: 1)Phaser 2: let sliceCoin = this.game.add.tween(this.coin, slice) sliceCoin.to({ y: game.config.height + this.apple.height, // x destination x: { // running a function to get different x ends for each slice according to frame number getEnd: function (target, key, value) { return Phaser.Math.Between(0, this.world.width / 2) + (this.world.width / 2 * (target.frame - 1));} } },gameOptions.throwSpeed * 6,Phaser.Easing.Linear.None,false,2000) sliceCoin.onComplete.add(function coinTweenCallback(tween) { this.state.start("Play") }, this) sliceCoin.start() And here Phaser 3: this.tweens.add({ // adding the knife to tween targets targets: [this.apple, slice], // y destination y: game.config.height + this.apple.height, // x destination x: { // running a function to get different x ends for each slice according to frame number getEnd: function(target, key, value){ return Phaser.Math.Between(0, game.config.width / 2) + (game.config.width / 2 * (target.frame.name - 1)); } }, // rotation destination, in radians angle: 45, // tween duration duration: gameOptions.throwSpeed * 6, // callback scope callbackScope: this, // function to be executed once the tween has been completed onComplete: function(tween){ // restart the game this.scene.start("PlayGame") } }); But Phaser 2 versions doesn't work. Sprite stay at static position.
  5. Appolos

    Tweens in Phaser

    Hello ! Can anybody help with Tween in Phaser. I need rewrite adding tween to game from Phaser 3 to Phaser 2. I have this code, how I can write it on Phaser 2. this.tweens.add({ // adding the knife to tween targets targets: [this.knife], // y destination y: this.target.y + this.target.width / 2, // tween duration duration: gameOptions.throwSpeed, // callback scope callbackScope: this, // function to be executed once the tween has been completed onComplete: function(tween){ some function ................ break; } }); Thaks !
  6. Appolos

    Phaser 3 Group

    Hello ! I created a group in my game, and I have arrows (left / right), and that's what I can not do: 1. I need to select only one element at a given time. 2. After pressing the left or right arrow, I need to move one element of the group to the next (for example, a slider). Please help to do this! Thanks !) Here is my code: this.rightArrow= this.add.sprite(game.config.width / 2+280, game.config.height/2,'rightArrow') .setScale(0.3) .setInteractive() .customParams = {direction:-1} this.left= this.add.sprite(game.config.width / 2-280, game.config.height/2,'rightArrow') .setScale(-0.3) .setInteractive() .customParams = {direction:1} let knifeData = [{ key: 'knife1', text: 'Areos', price: 100, }, { key: 'knife2', text: 'Winter', price: 100, }, { key: 'knife3', text: 'Scalpel', price: 100, }, { key: 'knife4', text: 'Hunting Knife', price: 100, }, { key: 'knife5', text: 'Bayonets', price: 100, } ] this.group = this.add.group(); knifeData.forEach(element => { this.group.create(game.config.width / 2, game.config.height / 2, element.key) this.group.create(game.config.width / 2, game.config.height / 2, element.key) this.group.create(game.config.width / 2, game.config.height / 2, element.key) this.group.create(game.config.width / 2, game.config.height / 2, element.key) this.group.create(game.config.width / 2, game.config.height / 2, element.key) })
  7. Appolos

    Plugins in Phaser&ES6

    Hello! Thanks for answer and creating this plugin. I want ask you how to use your plugin for creating display that resize to mobile screen size (creating response game) If you can help I'll be very grateful you.
  8. Appolos

    Plugins in Phaser&ES6

    Hello! Thanks for answer and creating this plugin. I want ask you how to use your plugin for creating display that resize to mobile screen size (creating response game) If you can help I'll be very grateful you.
  9. Appolos

    Plugins in Phaser&ES6

    I`m use in creating simple game - ES6 syntax, and I cannot add plugin to my game (phaser-plugin-game-scale). Help me and explain how to use plugin in ES6 syntax. Thanks!!