Tommy_

Members
  • Content Count

    20
  • Joined

  • Last visited

About Tommy_

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I'm trying to use phaser with classes, here is my code: class Boot extends Phaser.Scene { constructor() { super({key:'Boot', active: true}); } preload() { this.load.image('example', 'assets/example.png'); } } module.exports = Boot const Phaser = require('phaser') const Boot = require('./Boot') const Main = require('./preload/Main') class MyPhaser extends Phaser.Game { constructor() { super({ type: Phaser.AUTO, width: 800, height: 600, }) this.scene.add('Boot', new Boot(), true); this.scene.add('Main', new Main(), true); } create2() { new Main().create2() } } module.exports = MyPhaser class Main extends Phaser.Scene { constructor() { super({key:'Main', active: true}); } create() { this.add.image(200, 200, 'example') } create2() { this.add.image(400, 400, 'example') } } module.exports = Main now in the class Main inside of create i have access to the example image but the problem is in the create2 I don't have access to image example! I guess it's because this is referring to MyPhaser or something? I'm now good with classes. what is the problem and how can I have access to image example from create2 ?? BTW is this the right way to call function inside of one of the scenes? ( new Main().create2() ) Thanks,
  2. I have too many objects in my game and they are effecting badly on performance of the game. but since there are like two-five percent of them visible for a player at a time (got a pretty big game area) is there a way to not render the object that player can't see at a time? any other approach to fix this?
  3. I was wondering if it's possible to set something like id for every children of a group in phaser 3? so I can call them later by their id? In an other word How can I get specific child of a group.
  4. I have some sprites in a group with random x,y. and i want those x,y be somewhere on my lets say ground area (which is a circle graphic object). what is the best way to do this? I was thinking about something like this: in update check if the sprite x,y overlap (contains) with ground or not, if they do let them be if they don't destroy them and make an other random x,y and so on. but since those sprites are too many and overlap area (ground) it's not that big it would effect on performance I guess(it will?). So is there a better way to do this?
  5. Tommy_

    How to pass parameter with emit

    How can I pass a parameter with emit? var blabla = "bla" this.events.emit('something'); this.events.once('something', doSomething, this); function doSomething(blabla) { console.log(blabla) }
  6. Tommy_

    problem with space shooter lab example

    Thanks for explanation. but the problem is when using this.physics.velocityFromRotation(ship.rotation, 600, ship.body.acceleration); with second argument you could set "how long takes to reach the max speed" and setMaxVelocity was the max speed. this.physics.velocityFromRotation(ship.rotation, 600, ship.body.velocity); but when using this, the second argument is the max speed!!
  7. in this lab example there is something like snap to 45,135, -45, -135 angles. if you active debug mode and try to move to any direction but the ones i said you will notice it. like in the attach i'm aiming at bottom but i'm moving to 45. and it's stuck at 45. How can i make it to move to the angle i'm aiming for? like this (tried to change velocityFromRotation to velocityFromAngle but nothing changed) sorry I'm new and trying my best to explain it. tried to change it if (cursors.up.isDown) { this.physics.velocityFromRotation(ship.rotation, 600, ship.body.acceleration); }
  8. Tommy_

    How to fix a Image to a Sprite

    I'm trying to stick a hand to my player and I simply did this: hand.x = player.x + 40; hand.y = player.y - 40 the problem is my player rotates. so How can I fix the hand to the player. BTW hand need physical collision
  9. I have a platform game and I want my game to fit the page so in config i used this: width: window.innerWidth, height: window.innerHeight now the problem is when the player zoom out he can see more of the game world and i don't want that... I did some research and apparently there is no way to disable the browser zooming feature (right?), so how can I prevent user from zooming in the game?