lifesuxtr

Members
  • Content count

    23
  • Joined

  • Last visited

About lifesuxtr

  • Rank
    Member

Recent Profile Visitors

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

  1. Hi guys i am trying to combine phaser and meteor .I am thinking to use meteor for ui elements database and for some real time data and phaser for actuall game canvas. There are some github repos about this but they are all outdated(from 2015) Is there anyone who did that recently and help me ? thanks
  2. There is a problem with game.state.add() function.For some reason game is undefined. Uncaught TypeError: Cannot read property 'add' of undefined at Object.init (main.js:51) at main.js:58 var socket; // global bir socket değişkeni. socket = io.connect(); // server a bağlantı isteği gönderir. //Server bağlantı isteğini dinler ve clientlara başarılı olursa geri "connect" mesajını emitler. //Oyunun ekrana oturması için boyutları ayarlıyoruz.Browserla ilgili. var canvas_width = window.innerWidth * window.devicePixelRatio; var canvas_height = window.innerHeight * window.devicePixelRatio; //Oyunumuzu belirlediğimiz divin içinde yaratıyoruz. var game = new Phaser.Game(canvas_width,canvas_height,Phaser.CANVAS,'gameDiv'); var gameProperties = { //oyunun gerçek boyutları.oyun dünyasının genişliği ve uzunluğu. gameWidth:4000, gameHeight:4000, } //Oyunun ana state i. var main = function(game){ }; main.prototype ={ preload:function(){ }, create:function(){ // oyun yaratıldığında çağrılır. console.log("Client yaratıldı.") //serverdan connect mesajı gelince onSocketConnected fonksiyonunu çalıştır. socket.on("connect",onSocketConnected); //serverdan gelecek connect mesajı için dinler.Socket.io bir client // servera bağlandığında otomatik olarak connect mesajını client a gönderir. //serverın clientlara mesaj göndermesine "emit" denir. }, } function onSocketConnected(){ console.log("Sunucuya bağlanıldı.") }; var gameBootStrapper = { init:function(gameContainerId){ game.state.add('main',main); //error here game.state.start('main'); } }; gameBootStrapper.init('gameDiv'); My index.html: <body> <div id="gameDiv"> </div> </body> <script src="client/lib/phaser.js"></script> <script src="/socket.io/socket.io.js"></script> <script src ="client/main.js"></script> Here there is a picture of index.html: https://i.stack.imgur.com/N6jU3.png if i console.log(game) everything looks ok http://prntscr.com/j2jzty
  3. lifesuxtr

    How to load sprites on phaser based on database data

    Hello.Rıght now i dont have any states.game just starts immediately.Lets say that i want to start the game from subscribe.If i put all my functions into lets say a start state how do i reach game variable from that state ?(because i decleared it in ionViewDidLoad) right now my preload create update functions are right under ionViewDidLoad.I mean ionViewDidLoad(){ //this.game decleration } preload(){ } create(){ } update(){ } //so if i launch the page game immediately loads and starts. //If i try to move all above code to a state structure to call it from ionviewDidloads subscribe callback like: start = Object.assign(new Phaser.State(), { preload: function () { //how do i reach this.game from here ???? }, create: function () {} });
  4. lifesuxtr

    How to load sprites on phaser based on database data

    Thanks for the answer i guess using the promises is the best solution.I was reading about it and trying but couldnt make it work.can you give an example
  5. Hi thanks for the answer but i cant use that let gameOverState = { preload: function () {}, create: function () { // … onInputDown.add -> // game.state.start('game'); } }; structure in my typescript file.It says constructor method... needed for it.I am trying to create states in 1 file.
  6. lifesuxtr

    How to attach text on enemies

    Thanks... it worked
  7. lifesuxtr

    How to attach text on enemies

    I tried that too this is the result:
  8. lifesuxtr

    How to attach text on enemies

    I tried something similar to this i cant reach coordinates Cannot set property x undefined error
  9. lifesuxtr

    How to attach text on enemies

    this.zombies = this.game.add.group(); this.zombies.enableBody=true; for (var i = 0; i < 5; i++) { var zombie = this.zombies.create(this.game.world.randomX, this.game.world.randomY, 'zombie'); zombie.health=5; this.zombieHealthText=this.game.add.text(zombie.x, zombie.y, "5", { fontSize: '16px', fill: '#000' }); } I am trying to add text on moving enemies.This code creates text on their initial point.What should i write inside update function to make them stick to zombies while they are moving ?
  10. lifesuxtr

    remove

    i solved it
  11. lifesuxtr

    How to load sprites on phaser based on database data

    I know that.I just need to make preload function wait for db data to come.It works way to fast so i cant display db data.Somehow i need to create a state and call that state from inside subscribe
  12. I am trying to create a gamestate in phaser. The problem is typescript is not allowing me to do it by this Iam triying to put all functions into 1 state then call that state. let gameState = { //preload update create functions here }; After initializing game this.game.state.add('game', gameState); Then call state in subscribe this.game.state.start('gameState'); The problem is typescript doesnt let me to create a state with above let gameState structure.It says Unexpected token. A constructor, method, accessor, or property was expected.
  13. lifesuxtr

    Problem with Installing Plugin

    I am trying to install this plugin : https://github.com/matthiaswh/phaser-health-meter I put js file into this directory: Included it as : import {HealthMeter} from "phaser-ce/src/plugins/healthMeter" And as mentioned in documentation: this.player.health=50; this.player.maxHealth = 100; this.playerHealthMeter = this.game.add.plugin(Phaser.Plugin.HealthMeter); this.playerHealthMeter.bar( this.player, {x: 20, y: 100, width: 100, height: 20} ); This is the error: I guess im putting js file to wrong directory
  14. lifesuxtr

    problem with .damage oneshots

    I know its missleaing must be bullet and zombie