Arcanorum

Members
  • Content Count

    157
  • Joined

  • Last visited


Reputation Activity

  1. Like
    Arcanorum got a reaction from Nodragem in Socket.io and Oriented Object Paradigm   
    var _this; GameServer.prototype = { constructor : function(){ _this = this; }, onConnection : function(socket){ socket.on('new_player', _this.onNewPlayer(data)); } } I know it seems like a hack, but it is the cleanest solution that I use and lets me get stuff done easily.
  2. Like
    Arcanorum reacted to Str1ngS in Can't see html elements when Phaser Fullscreen is used   
    Hey there,
    Phaser uses the browser's build-in fullscreen API that will take any given HTML element, and make it stretch to your window's size. By default, Phaser passes the canvas element to make it full screen.
    What you want to do is change this fullscreen target (http://phaser.io/docs/2.3.0/Phaser.ScaleManager.html#fullScreenTarget) and pass the Element that contains both your UL and your canvas like so:

     
    //html <div id='wrapper'> <ul id='userList'> <li>user1</li> <li>user2</li> </ul> <canvas id='game'> </div> //js <script type="text/javascript"> game.scale.fullScreenTarget = document.getElementById('wrapper') </script>  
  3. Like
    Arcanorum got a reaction from samme in Issue with Inheritance, TypeError : this.onTextureUpdate   
    You need to study the examples more closely. https://phaser.io/examples/v2/sprites/extending-sprite-demo-2
    The order of how you assign things to the prototype matters.
    This is what your objects should look like:
    Item = function (game, x, y, sprite_name) { Phaser.Sprite.call(this, game, x, y, sprite_name); game.physics.enable(this, Phaser.Physics.ARCADE); // Bunch of properties }; /** * Assign the prototype of this object to the same prototype of Phaser.Sprite. * Do this BEFORE adding or overriding any properties on the prototype object * for this object, otherwise they will be overwritten. * * If you do Item.prototype = ... at the end, then the prototype property of * Item will reference a completely different object than the one that you * added .update to. */ Item.prototype = Object.create(Phaser.Sprite.prototype); /** * It doesn't really matter where you assign the constructor, as long as it is * after the declaration of the Item function. */ Item.prototype.constructor = Item; /** * Now that the prototype of Item is using the prototype of Phaser.Sprite, we * can override any functions that Phaser.Sprite has, such as .update, .render, etc. */ Item.prototype.update = function () { // Bunch of things };  
  4. Like
    Arcanorum got a reaction from PhaserEditor2D in What is the best way to organize work with designer?   
    Phaser Editor sounds like what you are looking for. http://phasereditor.boniatillo.com/
  5. Haha
    Arcanorum got a reaction from ecv in Error during chrome version change   
    How did this end up on the game showcase bar?

  6. Haha
    Arcanorum reacted to scheffgames in Low fps... is my game so advanced?   
    Actually the pool size has a big hit on performance - noticed this with my last game. Not crazy amounts even - 20 vs 40 objects made a significant hole in fps (-10, -15 fps). To be fair the sprites where 200x200px or bigger and my pc rig it's slow (which is good because I can catch perfomance drops quite easily  ). This hapened even though I used every optimization trick in the book - they were images not sprites, I killed them when they were off screen, etc. - probably had to do with PIXI having to deal with lots of texture data or something, don't know for sure and maybe it was solved in Phaser 2.7
    Solution - don't use a pool. With phaser 2.6 perfomance it's better with instantiating and destroying a large number of images/sprites.
  7. Like
    Arcanorum got a reaction from Otho in How to test the performance of a phaser game?   
    Should still work https://github.com/englercj/phaser-debug
    Read this if you haven't https://phaser.io/tutorials/advanced-rendering-tutorial
    Phaser is here to stay, and will only get bigger with v3.
    You can write slow code in any language. There is nothing inherently slow about JavaScript.
  8. Like
    Arcanorum got a reaction from Otho in How to test the performance of a phaser game?   
    Should still work https://github.com/englercj/phaser-debug
    Read this if you haven't https://phaser.io/tutorials/advanced-rendering-tutorial
    Phaser is here to stay, and will only get bigger with v3.
    You can write slow code in any language. There is nothing inherently slow about JavaScript.
  9. Like
    Arcanorum got a reaction from Otho in How to test the performance of a phaser game?   
    Should still work https://github.com/englercj/phaser-debug
    Read this if you haven't https://phaser.io/tutorials/advanced-rendering-tutorial
    Phaser is here to stay, and will only get bigger with v3.
    You can write slow code in any language. There is nothing inherently slow about JavaScript.
  10. Like
    Arcanorum got a reaction from mattstyles in Basic networked multiplayer game example/template   
    I just realised uWS is now the default websocket engine for socket.io 2.0.0. Good news.
    https://socket.io/blog/socket-io-2-0-0/
  11. Like
    Arcanorum got a reaction from mattstyles in How to detect if user is closing game   
    When a client disconnects, socket.io will automatically detect that they have disconnected and will fire the 'disconnect', and 'disconnecting' events.
    The only difference is that using the 'disconnecting' event will allow you to do stuff with the rooms the socket is in before it is removed from them.
    You could use an either an object or array to store a list of connected clients, identifiable by the ID of the socket connection for that client. Depends on how you like to access the client data.
    var clients = {}; io.on('connection', function(socket){ // Add the client that just connected to the list of active clients, using the ID // of the socket as the key to access the player data object for that client. clients[socket.id] = {id: '5a4b3c2d1', username: 'blahblah', hitPoints: 80 /*, etc: 'etc'*/}; socket.on('disconnecting', function(){ // Remove the client from the list of clients. delete clients[socket.id]; }); })  
  12. Like
    Arcanorum reacted to True Valhalla in Greetings from Famobi   
    A note to anyone working with companies like this: they will distribute your games far and wide. You will not be able to license your games to other publishers when Famobi is giving them away for free. These companies also devalue HTML5 games as a whole with this strategy, making it harder for other developers to sell their content. Why would a company pay $500 for a license when they are getting games for free?
    My advice is to not shoot yourself in the foot, and to support the developer community by maintaining realistic prices for HTML5 games.
  13. Like
    Arcanorum reacted to dnassler in how to create sprite animations dynamically   
    I just found a way! Thought I would share...  With help from another post related to dynamic image creation I was successful by doing the following:
     
    in the game loader I created a bitmapData object and drew to it using the bitmap context drawing methods then got the bitmap data's canvas and from that did a toDataURL... then did a game.load.spritesheet with the dataURL as if it was an image file.
    var dataURL, bmd, ctx, width, height;width = 100;height = 100;bmd = game.add.bitmapData( width * 2, height );ctx = bmd.context;bmd.clear();ctx.fillStyle = "#2E8B57";ctx.fillRect(0,0,width,height);ctx.fillStyle = "#FFFFFF";ctx.fillRect(0,0,width/2,height/2);ctx.fillRect(width/2,height/2,width/2,height/2);ctx.fillStyle = "#2E8B57";ctx.fillRect(width,0,width,height);ctx.fillStyle = "#FFFFFF";ctx.fillRect(width+width/2,0,width/2,height/2);ctx.fillRect(width,height/2,width/2,height/2);dataURL = bmd.canvas.toDataURL();game.load.spritesheet('myDynamicSpritesheet', dataURL, width, height); The above creates a spritesheet of 2 frames dynamically... of a box composed of smaller green and white boxes.
  14. Like
    Arcanorum reacted to sanojian in Using bitmap data as a sprite sheet.   
    Which part, the first question or the followup question?  I have an example of creating a sprite sheet from a BitmapData object in my game blog:
     
     
    Build a Dynamic Texture Atlas in Phaser
  15. Like
    Arcanorum got a reaction from Firenibbler in Basic networked multiplayer game example/template   
    Greetings!
    I see quite often around these parts and in further fields, that there are constantly people who are just starting out asking how to add networked multiplayer functionality to their HTML5 games. I was one of them, and I hated the near absence of practical explanations that were written in concise, plain-English, yet still detailed, of how to get started.
    So, I made a simple game example/template using Socket.io and Phaser, and documented the hell out of it. Almost everything gets a few lines of comments to explain what is doing what, and I haven't assumed any prior knowledge, aside from core JavaScript and being able to set up NodeJS and how to view the game in a browser. The main focal point is using Socket.io, as the game framework can be easily interchanged to one of your preference.
    Hopefully this will save a few hours and headaches for people who don't have a clue what they are doing.
    https://github.com/Arcanorum/basic-networked-multiplayer-game
  16. Like
    Arcanorum got a reaction from Dread Knight in Make my game online multiplayer   
    I've made a GitHub repo for that thing I showed you in the Discord chat. I've added a bunch of new stuff to it, like having players join a game, how to handle player movement, updating the positions of all players on the client, and removing players when someone leaves.
    https://github.com/Arcanorum/basic-networked-multiplayer-game
  17. Like
    Arcanorum got a reaction from Firenibbler in Basic networked multiplayer game example/template   
    Greetings!
    I see quite often around these parts and in further fields, that there are constantly people who are just starting out asking how to add networked multiplayer functionality to their HTML5 games. I was one of them, and I hated the near absence of practical explanations that were written in concise, plain-English, yet still detailed, of how to get started.
    So, I made a simple game example/template using Socket.io and Phaser, and documented the hell out of it. Almost everything gets a few lines of comments to explain what is doing what, and I haven't assumed any prior knowledge, aside from core JavaScript and being able to set up NodeJS and how to view the game in a browser. The main focal point is using Socket.io, as the game framework can be easily interchanged to one of your preference.
    Hopefully this will save a few hours and headaches for people who don't have a clue what they are doing.
    https://github.com/Arcanorum/basic-networked-multiplayer-game
  18. Like
    Arcanorum reacted to Crisu83 in Running Phaser on Node.js - How I did it and why you shouldn't do it   
    Hello All,
     
    I am working on a multiplayer action role playing game and I am using Phaser on the client because I just love this framework.
     
    Here is a link to the project on GitHub:
    https://github.com/crisu83/dungeon-game/tree/feature/phaser-server
     
    I have been experimenting quite a lot with running Phaser in headless mode on the server and I managed to get it to run with a few hacks.
     
    I am not sure that it is a good idea to run Phaser on the server, but I am looking into this because I would prefer to have an authoritative server that runs on the same code base as my clients.
     
    Here is what I did in order to get Phaser running on the server:
     
    First I installed the latest stable version of Phaser through NPM by running the following command:
    npm install http://github.com/photonstorm/phaser/tarball/v2.0.5 After that I installed the dependencies for Node Canvas, instructions for that can be found in the project wiki on GitHub:
    https://github.com/LearnBoost/node-canvas/wiki
     
    Next I installed node-canvas and jsdom through NPM. These modules are required in order to "fake" the document, window, canvas and image objects that Phaser depends on that all are available in all browsers, but not on Node.js.
    npm install jsdomnpm install node-canvas Then I wrote this wrapped module for Phaser:
    https://gist.github.com/crisu83/5857c4a638e57308be4f
     
    I know that this is a ugly hack, but it at least lets me run Phaser on the server.
     
    Here is what the server currently outputs:

     
    I am now wondering if I should attempt to make changes to Phaser itself to not rely on the document, window, canvas, image when running in headless mode and create a pull-request for the changes. I am sure it will not be easy to remove all those dependencies, if even possible.
     
    Does anyone know if Richard has any plans for this? Does this even make sense to run Phaser on the server?
     
    Please share your ideas and feel free to use my code for your own projects.
     
    Thank you for reading.
  19. Like
    Arcanorum got a reaction from Igor Georgiev in The Phaser 3 Wishlist Thread :)   
    Some swanky Phaser t-shirts. 
  20. Like
    Arcanorum got a reaction from Igor Georgiev in The Phaser 3 Wishlist Thread :)   
    Some swanky Phaser t-shirts. 
  21. Like
    Arcanorum got a reaction from WiLD11 in What is your favourite Phaser plugin?   
    Text input. Phaser needs something like this out of the box IMO. https://github.com/orange-games/phaser-input
  22. Like
    Arcanorum got a reaction from Kraken in Try my flappy bird game   
    What does obfuscation have to do with security? If players want to mess with the game then they are within their right to do so once you send their client the files. Without a way to truly compile our games there isn't much that can be done to stop others from working out how our code works. Minification is what you should be concerned with.
  23. Like
    Arcanorum got a reaction from Igor Georgiev in The Phaser 3 Wishlist Thread :)   
    Some swanky Phaser t-shirts. 
  24. Like
    Arcanorum got a reaction from JokerJESUS in Phaser Text Editor/IDE autocomplete API   
    WebStorm all the way baby...
  25. Like
    Arcanorum reacted to rich in The Phaser 3 Wishlist Thread :)   
    Yeah don't worry, I hear you. Even in its current infant form Lazer has fully decoupled rendering. The renderer is now literally just that, it renders what it is given and has absolutely no influence over things moving in the scene (unlike how Pixi works via its deferred transforms).