michebn

Members
  • Content Count

    9
  • Joined

  • Last visited

  1. michebn

    GameConfig

    In case you were looking for the parameters you can actually have in that config object: Looks like you have to dig through the code: https://photonstorm.github.io/phaser3-docs/boot_Config.js.html The config class can be found here: https://photonstorm.github.io/phaser3-docs/Phaser.Boot.Config.html Not much Infos there anyway...
  2. I'm still new to js so I can't help you with the this vs. Container problem. From an algorithm point of view here is what I would try: First: In your create function, call makeBlocks and moveBlocks because currently, you initialize your blocks but don't add force to them so the don't move and your if clause will never be true (the affor mentioned if clause is true if the block has moved out of the left side, so no movement no if) Second: in the if clause you have to call makeBlocks as well (bevor the move call) so that a new row of blocks will be created (and force added to them). I.e. The make and the move call always have to go together otherwise you ether add new blocks without force (movement) or you set movement to old / gone blocks Edit: you might actually not get an error currently because your move function is never called...
  3. Looking at the names of the functions and the comment, I guess //if off the screen reset the blocks if (fchild.x < -this.game.width) { this.moveBlocks(); } } Should be //if off the screen reset the blocks if (fchild.x < -this.game.width) { this.makeBlocks(); } } (Note: it's makeBlocks not moveBlocks) Because that's the part were you destroy old blocks and create new blocks (look at the tutorial again). The moveBlocks call should probably go after that if statement but you should recheck the tutorial (didn't find the call but I didn't spend to much time searching ether...)
  4. I'm on my phone so I can't check it but it seems that teens have a stop method : https://labs.phaser.io/edit.html?src=src\tweens\immediate stop a tween.js So saving the tween and calling stop before creating a new one might do the trick var tween = null; //global or in a class ... if (tween) tween.stop() tween = this.tweens.add(...) Something like that...
  5. I'm still a phaser beginner, so I'm not sure the following helps: You can easily load images at runtime (see e.g. https://labs.phaser.io/edit.html?src=src\loader\image\load image on click.js) though I think they have to be in the webspace already. You could probably use any standard technology to upload an image to a given path and than load it in phaser. Regarding the drag and drop there is functionality for this (see e.g. https://labs.phaser.io/edit.html?src=src\input\dragging\stack of cards.js). I think it should be easy to adjust this example to move the image back to its original position, if the image is on an invalid position at drag stop. Again: I have not done any of these. Take a look at https://labs.phaser.io/index.html, it's a very valuable resource regarding any Phaser3 stuff.
  6. Since your posting in the Phaser3 area, I assume you are already using Phaser3, which comes with a Physics library already. You will have to add your course and your ball to the physics engine. Then you can simply set the x/y velocity of the ball and the collision/bouncing will be handelt by the physics engine. The Phaser3 lab examples may guide you. Most of the examples activate gravity, but you can just leave it out. Make sure to activate bouncing though, otherwise your ball will probably just halt at walls. (Physics examples: https://labs.phaser.io/index.html?dir=physics/arcade/&amp;q=) Looking at the network part: Depending on your players you could simply "trust" the clients and let them do the physics calculation only (broadcasting the velocity to all clients) but that opens doors for cheating. To avoid cheating you can also run the physics on the server and syncing states with all clients. It may be enough to sync the ball position bevor the next shot, but that may lead to some ball repositioning. Alternative you could try to reposition the ball every other frame (or fewer/more often). Not sure how well it works but it would be worth a try.
  7. Since I had the same issues a couple of days ago, here is what I found out: (not sure I got everything correct, but it may help you) With nativ Javascript (with compatibility for all browsers) there is no such thing as an import, so you ether push all classes in one file in the correct order, add the files in the correct order to your index.html or (probably the best way) use some transpiler that does the magic for you. If you happen to have such a transpiler setup up and running, the exact syntax depends on that setup. With ES6 (and Bable) you would write something like import { Player } from "player"; With typescript the Syntax would be similar but you need to add `export` to your Player.js file, i.e. // player.js export class Player { ... } // game.js import { Player } from "player"; Node.js uses a require Function, but I'm not quite sure what the syntax is. It's something like var player = require('player'); // ... player = new player.Player(this); In case you just use plain javascript, I would advise you to setup a toolchain, that does manage the complicated stuff for you. For Phaser3 you may take one of the templates from here, there is support for ES6, TypeScript and Coffescript, with live reload and deployment. It's very easy to setup and your project gets a lot more structured.
  8. Hey. I'm a Javascript beginner to (coming from cpp/python) so I'm not sure I understood it correctly, but as far as I know the order of the script mathers... When the browser reaches your testmain.js it trys to run it and therefor create your game. But at this time, your other scripts didn't run and therefor your scenes are not defined. So you could try moving your main script at the end or (probably even better) use window.onload = function () { var game = ... } Not sure if this is the problem though.. Edit: As noted in the other post, it might be helpfull to set up some sort of development toolchain that handels all the importing stuff for you... It helped me to get something on the browser anyway.
  9. Hey, since I'm coming from the CPP / Python world, this helped me a lot on starting my first weg game (the web world seems a lot more complicated than anything in C++ anyway xD) I tryed setting up a unit test frame work (tryed karma + jasmin and jasmin standalone but failed with both). I got karma running with plaine JavaScript (not with this template) but i would like to have the Typescript version. I don't bother if it's via console or via browser reload ... so do you guys know an easy way to set up any unit test framework with the typescript template here?