ldd

Members
  • Content Count

    71
  • Joined

  • Last visited

Everything posted by ldd

  1. You should post on the new forums: https://phaser.discourse.group As for your question, I'd guess playing with `scene.start()` and `scene.sendToBack()` should work. Anyways, please use the new forum. Thanks!
  2. You are making the right type of mistakes! (which is good) try this: let fn = ()=>false; console.log( fn == true && true, fn && true); a function is truthy, but when compared to true with ==, it will return false. This seems voodo magic until you read the specs[0][1] ps: there is a difference between fn, and fn(), just like in your example. You'd need `condition(count)` to make it work [0] http://www.ecma-international.org/ecma-262/5.1/#sec-11.9.3 [1] http://www.ecma-international.org/ecma-262/5.1/#sec-11.8.5
  3. Adding a parameter where needed[0]: function preload() {...} function create() { ... fun1(this.game, a, b, etc) } function update() { ... fun2(this.game, a, b, etc); fun3(this.game, a, b, etc) } function fun1(game, etc) {...} function fun2(game, etc) {...} function fun3(game, etc) {...} module.exports = { // Calling this file as state object later preload, create, update } Or using IIFE var App = (function(api, game){ api.game = game; function preload() {...} function create() { /* use api.game to access game instead of this.game */ /* read the docs, and see how you can get away with cleaner code that doesn't rely on binding */ } function update() { ... fun2(); fun3() } function fun1() {...} function fun2() {...} function fun3() {...} //expose stuff api.preload = preload; api.create = create; api.update = update; return api; })(App || {}, this.game /* or other stuff that I can't remember*/) In fact, I'd recommend going this route if you want to stick to ES5 because it simplifies your life, AND you are very free to use multiple files to separate concearns, only expose what you want,etc. Lastly, you may consider ES6 and Webpack (which makes everything butter smooth) import 'pixi'; import Phaser from 'phaser'; import BootState from './states/Boot'; import SplashState from './states/Splash'; import MenuState from './states/Menu'; import PlayState from './states/Play'; /** Class representing a game. * @extends Phaser.Game */ class Game extends Phaser.Game { /** * @constructs Create a game. When done, go to the {@link Boot} state. */ constructor() { let width = document.documentElement.clientWidth; let height = document.documentElement.clientHeight; let config = {/*[REDACTED for brevity] */}; super(config); // Add all necessary game states this.state.add('Boot', BootState, false); this.state.add('Splash', SplashState, false); this.state.add('Menu', MenuState, false); this.state.add('Play', PlayState, false); this.state.start('Boot'); } } new Game(); [0] http://pmuellr.blogspot.ca/2010/06/bind-considered-harmful.html Anyways, some suggested readings on the topic: [1] https://github.com/getify/You-Dont-Know-JS/blob/master/scope %26 closures/apC.md [2] https://github.com/getify/You-Dont-Know-JS/blob/master/this & object prototypes/README.md#you-dont-know-js-this--object-prototypes [3] https://codereview.stackexchange.com/questions/49872/using-var-self-this-or-bindthis
  4. Does this example help? https://phaser.io/examples/v2/input/drag If not, there are other examples here: https://phaser.io/examples/v2/category/input Otherwise, I think trying to list the things you want to accomplish would help. I'd guess you want to do something like 1) click on structure 2) drag structure to map 3) leave structure in map Most of that is just a combination of the tutorials that I linked, so hopefully you figure it out
  5. const addOnce = (keyString, self) => { const key = game.input.keyboard.addKey(Phaser.Keyboard[keyString]); key.onDown.addOnce(self.start, self); } or maybe even const addKeys = (keyStrings, self) => { keyStrings.forEach( (keyString) => { const key = game.input.keyboard.addKey(Phaser.Keyboard[keyString]); key.onDown.addOnce(self.start, self); }); } //usage addKeys(['W','A','S','D'], something);
  6. I think they meant const add = (list, item) => list.concat(item) //example add([3,4],5) //output is [3,4,5] otherwise you have a function that returns a function and you'd use it like so: const add = list => item => list.concat(item) //example add([3,4])(5) //output is [3,4,5] (keep in mind that in functional programming you'd rather use `concat` rather than `push` )
  7. Couple of quick pointers: 1) Avoid using function names that closely match reserved words or already existing native code. Array.prototype.forEach already exists, so avoid names like 'forEach' 2) is_exist sounds weird, and can be simplified: const is_defined = (obj) => obj !== undefined just keep in mind that there are better check than this, and consider cases like when obj is null, etc (be careful when doing comparisons and read on the topic) 3) you are trying to use a method that can be accessed by each individual item in an array. If it is always hide, you can simply do const hide_enemies = (enemies) => enemies.forEach( (enemy) => enemy.hide() ); or if you need to call other methods, just use a string to represent a possible method name const hide_enemies = (enemies, actionString) => enemies.forEach( (enemy) => enemy[actionString]() ); In old-school syntax, you could write function hide_enemies(enemies){ enemies.forEach( function(enemy){ return enemy.hide(); }); } If you tell me more about why you are checking is_exist(obj[0]), we could probably avoid awkward checks. Finally, you could check out this quick guide to Array functions that may provide you with more information.
  8. from my experience, and plenty of other people's experience, it is 'bullets against bullets' that is causing your problems. If you can, disable that type of collision. If you absolutely must have bullets against bullets or other things, consider making less collisions anyways (maybe bullets only collide before 1 second has passed away, or only if your level is high, etc) In general, avoid collisions as much as you possibly can.
  9. Phaser examples are in another repository, away from the main phaser project. https://github.com/photonstorm/phaser-examples Just clone and download that repo ;D
  10. ldd

    AsterWaster Game

    Interesting idea! Some comments: - It should be "Let's Battle". Spellcheck your game. - your UI needs a lot of work
  11. per the documentation: new Phaser.Image(game, x, y, key, frame) so you are missing an argument to specify the frame ps: why is this forum using a rich text editor and not markdown? +.+
  12. var myArray = []; function doStuff(arr){ for (var i=0; i< 3; i++){ arr[i] = function(){ console.log(i); } } } doStuff(myArray); myArray[0](); //3 myArray[1](); //3 //fix with ES6 let function doStuffImproved(arr){ for(let k=0;k < 3; k++){ arr[k] = function(){ console.log(k); } } } doStuffImproved(myArray); myArray[0](); //0 myArray[1](); //1 //fix with forEach function doStuffOther(arr){ return arr.forEach(function(el,l){ console.log(l); } } doStuffOther(myArray); myArray[0](); //0 myArray[1](); //1 //fix with closure //etc You need to learn a little bit more javascript to avoid these types of errors.
  13. physics are opt-in, not opt-out. If you do not need physics, just don't use them. On the other hand, aer you asking about disabling physics AFTER enabling them before?
  14. is this still under active development?
  15. https://github.com/Brad-Chapin/daky-in-monsterland/blob/master/js/main.js Your code doesn't include a tilemap. Follow this example: https://phaser.io/examples/v2/tilemaps/blank-tilemap Additionally, looking at your repo, I cannot find a tileset in https://github.com/Brad-Chapin/daky-in-monsterland/tree/master/assets Are you sure you included it, and pushed to github your latest code?
  16. I usually just reply to people asking questions, but I thought I'd show some open-source tools that you could potentially use in your games: https://github.com/ldd/tech-tree-js (source) minimally display a tech tree (I did this a long time ago, and I don't really know if anybody would want me to continue working on it, but basically it lets you display a tech tree and store it fantasy map generator (source) another thing I've just started working on, which uses the code made by Martin O'Leary and attempts to quickly show the user fantasy maps. you can colour them too! yay! Anyways, those are somewhat interesting ideas that I had for games that I never really ended up using anyways... since they are MIT-licensed, I thought maybe somebody would be interested in using them and giving me feedback.
  17. I'm not entirely sure that phaser works 100% on node, without at least a fake canvas and jsdom... again, after some googling here is a forum thread that might be interesting to you
  18. after some googling: app.use(express.static(__dirname + '/public'));
  19. 1. my browser: google chrome, latest version x64 macbook pro 2014 2. no probs. 3. no probs. 4. glad to hear! 5. that's ok, my only concern was that not ALL players would notice and it might affect their perception of the game. Maybe talk about it in one of your hints? Anyways, it doesn't really matter because it is a design choice. Also, do not misunderstand me! I loved the game! and the art!
  20. Not OP, but it boilds down to 1) artistic choice 2) AA is bad news if you have pixel art with certain qualities (e.g palette shifts, fake AA, fake transparency, etc)
  21. 1) I never really completely understood the camera, but play around with the values that you are passing to it. Worst case, take a look at the code ;D 2) you should use: map.setCollisionByExclusion([], true, boundary); 3) It is possible that the assets haven't finished loading, and you are starting the game too soon. At any rate, you should have a menu screen (or at least a button that starts the game.) All games do this, to some extend or another, so you are just playing it safe. If you are using webpack2, you can use a flag to autostart the game inside a setTimeout if(__DEV__){ setTimeout( () => {this.state.start('Play');}, 0); } so that it doesn't feel slow while developing the game.
  22. I'll write my post in English, so that everyone understands, mais je crois que le développeur est francophone et il y a un bug qui pourrait être le résultat de la langue du clavier... anyways. Awesome game! I noticed a couple of bugs 1) If you disable music, then reenable it and disable it again before starting the game, the game will not work. 2) the transparency of the dialog of the NPCs should be changed. You can see the 'charge meter' and it looks bad 3) the option to change your name is tiny, almost invisible 4) Apostrophes are sometimes missing. Like I mentioned before, you could potentially write apostophes with "'" or "`", and sometimes when changing keyboard layout certain characters will not be preserved... it's weird, but you should check that part 5) you can add more than 4 'powers', but there is no indication that this is possible in the UI Anyways! besides those tiny bugs, I found the game to be very interesting and compelling. The mechanics may appear simple at first glance, but there is enough depth to avoid repetition. PS: I loved the wolf ;D
  23. I'm not aware of a phaser-specific plugin, but you are in JS land. After some googling, I found: - qrcodejs (canvas) - https://github.com/pinchtools/qrcodesvg (svg)
  24. ldd

    Questions on Phaser

    1. Technically speaking, if by 'lag' you mean 'noticeable delay between the action of players and the reaction of the server in a video game.', then yes, it is absolutely possible to create a lag free game. The devil is in the details. Without going into a whole set of articles, it just requires reading and a healthy attitude towards networking. Whether you do your game in unity, unreal or phaser, there is always a lot of reading to understand how networking works and how to effectively do it. Supporting hundreds or thousand of players is harder than supporting a tactical turn-by-turn game for two players. Then again, the likelihood that you'll have more than a dozen players is quite low. Most MMO projects fail, and if this is your first networking game, I'd seriously consider not supporting more than two or three players. Maybe ten? That's a lot already. 2. Typescript is a superset of javascript. You can use only typescript if you feel more productive that way. No worries either way.
  25. The most important part is to consider whether you want a 'grid' (made of squares) where your character can move, rectangles, simple convex polygons or something more abstract. Once you've made that choice, we can help more. The easiest would be a grid of uniform squares, because you can then use say, tiled, 1 tile and then mark that tile as not passable. (2 lines of code?) /// map.setCollision(40) //game.physics.arcade.collide(p, layer); With rectangles, using arcade physics it is also trivial to define three rectangles in your image above where the character is not supposed to collide with your background. With convex polygons, using p2 collision you are also set. With more weird shapes, you are on your own (mostly) and it's hard. As for pathfinding, I think there's a A* plugin for phaser, otherwise implementing your own should be trivial (use a A* library, send initial and goal positions, get a result, use in in your game)