giorg

Members
  • Content Count

    35
  • Joined

  • Last visited

  1. Hello, in my create I have: this.anims.create({ key: '_chestwaiting', frames: this.anims.generateFrameNames('chestwaiting'), repeat: -1 }); then later with a for cycle I do: for (let i = 0; i < 3; i++) { chests[i] = this.add.sprite(this.chests_positions[i].x, this.chests_positions[i].y).setOrigin(0, 0).play('_chestwaiting') but this way all 3 are synchronized waving up and down, so I wonder if there is a way to make them start with a random frame... hope I've been clear. Thanks a lot
  2. I must be VERY tired, I could not see it... thanks a lot!
  3. hi, I'm doing this which works perfectly: let man = this.add.image(-416, 128, this.man).setOrigin(0, 0); this.tweens.add({ targets: man, x: 0, duration: 2000, ease: 'Power1' }); to show a picture coming out from left side of the screen. Now I need, after a while to make the opposite, so trying: this.time.delayedCall(2500, () => { this.tweens.add({ target: man, x: -416, duration: 2000, ease: 'Power1' }); }, this); but I'm getting this in console: Uncaught TypeError: Cannot read property 'length' of null the error is on the add method. What am I doing wrong? Thanks a lot
  4. giorg

    resize question

    thank you so much!
  5. giorg

    resize question

    hey andrew, the problem is that on resize (even at runtime) I have to interact with phaser scenes, so I cannot put it outside the game... thanks
  6. giorg

    resize question

    hello, I have this in my scene's create: window.addEventListener("resize", this.resize(), false); then at the same level of the create I put: resize() { alert(window.innerWidth) } anybody can explain me why this is working only the first time I load the game, but not when I resize the window? thanks
  7. Hi, we would like to lighten the game loading/playing, is possible to disable/remove unused scene features? For example, if a scene doesn't need cameras, or update cycle, is to possible to remove them? thanks a lot
  8. Hi, I have an audio sprite which I need to play and if the user clicks somewhere I need to interrupt it. This is what I tried: - in my create function: this.winsound = this.sound.addAudioSprite('bonussounds', 's4bonusmusic', {loop: true}); // to add my sound to the sound manager then I thought ok, with this.winsound.play() and .stop() I will be able to manage it. Instead, they do nothing, no errors in console. how to correctly manage audiosprites with my requirements? thanks a lot
  9. giorg

    anims and scenes

    got it, thank you!
  10. giorg

    anims and scenes

    hey rich, thanks for your answer. I'm trying to create the animations in the preload function of my Boot scene, where I load all the assets. But when I do: this.anims.create({ key: 'cassa0', frames: this.anims.generateFrameNames('cassa_attesa', { start: 0, end: 59, prefix: 's4b2cassaattesa_', zeroPad: 4 }), repeat: -1, }); in there (ofc before I do this.load.multiatlas('cassa_attesa', 'cassa_attesa.json'); which works), when I enter my scene I try this.add.sprite(510, 450).play('cassa0'); but I get TypeError: Cannot read property 'frame' of undefined. so I don't know how to access the animation... thanks for any help
  11. giorg

    anims and scenes

    Hi, I have 3 scenes, with different animations inside the create() of each one. When I do the launch of the second scene from the first one, all is ok, but when I try to launch 3rd scene, in console I get: Invalid Animation Key, or Key already in use for each of the animation of that scene, as if they were already created, then the 3rd scene is not working. Also I might need to start the same scene again, how to achieve this? thanks
  12. @rich because that animation is too quick, I need it to disappear but if I just set hideOnComplete it disappear too quickly... pls see attachment: when user clicks a diamond, there is an animation on the diamond itself, which disappears, then an animation with written "Win" should appear on top of disappeared diamond. only x and y are changing every time this animation appears, so I wanted to isolate it in a function to call every click... thanks
  13. Hi, this function: playWin(idx) { console.log(idx) let c = this.anims.create({ key: '_win', frames: this.anims.generateFrameNames('win', { start: 0, end: 24, prefix: 's4b2win_', zeroPad: 4 }), repeat: 0, }); let answer = this.add.sprite(bonusplay_results[idx].x, bonusplay_results[idx].y).setOrigin(0, 0).play('_win'); setTimeout(function () { answer.destroy() c.destroy(); }, 2000); } is called every time the user click on a certain point... the first time works perfectly the second I get the error: Invalid Animation Key, or Key already in use: _win what am I doing wrong? thanks a lot
  14. hi all, I've written this code: let man = this.add.sprite(490, 400).setScale(0.6).play('man'); for (let i = 0; i < 5; i++) { let x = 140 + (186 * i); let x_anim = 47 + (224 - 117); diamonds[i] = this.add.image(x, y, 'd' + (i + 1)).setInteractive().on('pointerdown', function () { man.play('open_' + (i + 1)); man.on('animationcomplete', this.openComplete); this.diamondClicked(diamonds[i]); this.add.sprite(x_anim, y_anim).play('diam' + (i + 1)); }, this); } function openComplete() { this.play('man'); } this generate five diamonds, with the man animation waiting for the user to click them. Whatever I choose, always after second click I get that error "RangeError: Maximum call stack size exceeded". If I comment out this.play('man') inside the openComplete function, I get no errors and I can click all of them, but ofc the man animation waiting is not running anymore. What am I doing wrong? Thanks a lot