lifesuxtr

Members
  • Content Count

    27
  • 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. lifesuxtr

    Can Detect Collision but bodies pass through p2 physics

    I am still having this issue.btw i am moving player with changing coordinates.adding to x y values basicly
  2. For some reason in my game i can detect collisions but bodies are actually not colliding they are passing through. This is how i create player: player_coll function fires perfectly fine on collision. } My preload function: As you see in the picture why they are passing through ?
  3. Hi guys i am trying to load a background image on canvas and position game camera on certain position and zoom level. This is the example background image: http://i.hizliresim.com/3zYlaA.png When i load the image it looks like this: I want to set position of background image (or camera ? )like this: Canvas is 800x600 const preload = () => { game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; game.load.image("background", "http://i.hizliresim.com/3zYlaA.png") }; const create = () => { cursors = game.input.keyboard.createCursorKeys(); background = game.add.tileSprite(0, 0, 800, 600, 'background'); // Creates a layer from the World1 layer in the map data. // A Layer is effectively like a Phaser.Sprite, so is added to the display list. }
  4. I am trying to load tiled map from a json object but i am having this error : TypeError: data.trim is not a function var game; var myjsonmap = { "height":40, "infinite":false, "layers":[ { "data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "height":40, "name":"mymap", "opacity":1, "type":"tilelayer", "visible":true, "width":40, "x":0, "y":0 }], "nextobjectid":1, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.1.5", "tileheight":32, "tilesets":[ { "columns":16, "firstgid":1, "image":"wood_tileset.png", "imageheight":512, "imagewidth":512, "margin":0, "name":"wood_tileset", "spacing":0, "tilecount":256, "tileheight":32, "tilewidth":32 }], "tilewidth":32, "type":"map", "version":1, "width":40 } var layer; var map; const preload = () => { game.load.tilemap('sanayiort', myjsonmap, Phaser.Tilemap.TILED_JSON); // Next we load the tileset. This is just an image, loaded in via the normal way we load images: game.load.image('tiles', 'wood_tileset.png'); }; const create = () => { game.stage.backgroundColor = '#787878'; // The 'mario' key here is the Loader key given in game.load.tilemap map = game.add.tilemap('sanayiort'); // The first parameter is the tileset name, as specified in the Tiled map editor (and in the tilemap json file) // The second parameter maps this name to the Phaser.Cache key 'tiles' map.addTilesetImage('wood_tileset', 'tiles'); // Creates a layer from the World1 layer in the map data. // A Layer is effectively like a Phaser.Sprite, so is added to the display list. //layer = map.createLayer('World1'); // This resizes the game world to match the layer dimensions //layer.resizeWorld(); }
  5. 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
  6. 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
  7. 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 () {} });
  8. 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
  9. 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.
  10. lifesuxtr

    How to attach text on enemies

    Thanks... it worked
  11. lifesuxtr

    How to attach text on enemies

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

    How to attach text on enemies

    I tried something similar to this i cant reach coordinates Cannot set property x undefined error
  13. 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 ?
  14. lifesuxtr

    remove

    i solved it