phaser-framework

Meteor and Phaser - error loading asset

天涯浪子 提交于 2020-01-07 09:03:48
问题 I run Phaser with Meteor I get an error when loading a .png file from the directory. Could someone please provide some guidance on how to fix it. My environment is ubuntu 14.04 Meteor 1.1.0.2 Phaser v2.3.0 My directory structure and folders are cmt@ubuntu:~/projects/myMeteorProjects/issueReplication2$ ls -R .: client index.css index.html public server ./client: client.js phaser.js ./public: car.png index.html is <head> <title>phaser and meteor</title> </head> <body> <h1>Phaser and Meteor</h1>

Typescript extends keyword not working

倖福魔咒の 提交于 2020-01-07 06:55:32
问题 I'm developing my first game using Visual Studio, Phaser and Typescript. I can't get my classes to work when I use the extends key word This works: class Game { game: Phaser.Game; constructor() { // init game this.game = new Phaser.Game(window.innerWidth * window.devicePixelRatio - 20, window.innerHeight * window.devicePixelRatio - 20, Phaser.CANVAS, 'content', State); } } This does not: class Game extends Phaser.Game{ constructor() { // init game super(window.innerWidth * window

Function for adding object in Phaser

安稳与你 提交于 2020-01-07 03:19:25
问题 I need function like this, but for Phaser. wade.addSceneObject(new SceneObject(dotSprite, 0, dotPosition.x, dotPosition.y)); 回答1: Based upon how I understand your question, I'd highly recommend looking at a Phaser tutorial before you go too much further. The official tutorials are really quite good. Based upon the documentation for WADE I see that addSceneObject adds an object and SceneObject creates one. So, you want to know how to add a sprite to a game. In Phaser this would be something

Create a High Score in Phaser

人盡茶涼 提交于 2020-01-06 15:03:29
问题 This is my first time creating a game via a tutorial which I've coded along with so I am a completely new at this but I am eager to learn. I've this game "Bunny Defender" and want to create a simple High Score which I can store in some kind of localstorage with XML and display the high score result out on the screen when the game is over. I don't know how to do this and where to start. Would be very thankful if someone could point me at the right direction and how to manage this? // All the

Timer not working inside function in Phaser 3

[亡魂溺海] 提交于 2020-01-06 06:48:20
问题 I have a spawn function which performs some task. Before the function returns, I would like to delay some another function call. I tried using time.addEvent but with no luck as it does not seem to work within the spawn function. However the timer works perfectly inside the create function. My code so far: create(){ newMethod = spawn.bind(this); newMethod(); } function spawn(){ //do stuff timer = this.time.addEvent({ delay: 3000, callback: functionDelay, loop: false }); } function

Handling multiple Stages with multiple .js files

℡╲_俬逩灬. 提交于 2020-01-05 03:35:10
问题 So basically, i want to create a platformer or labyrinth game(Yes, very basic since im still learning, there wont be much stuff anyway). I want to have multiple .js files, each handling different tasks, for example: main.js - Game menu level1.js - Level 1 of the game level2.js - Level 2 of the game winlose.js - Similar to game menu, just showing if you win or lose the game(Possible Restart -> swap back to main.js) What i got so far is the basic game(currently still in the main.js) var

Using Phaser together with React

感情迁移 提交于 2020-01-02 04:33:05
问题 I am trying to understand how I could use React for rendering all the UI elements and Phaser for rendering a game (using Canvas or WebGL) within the React application. One way would be to use React's componentDidMount, so after I have my HTML ready I can use a div id to render the Phaser content. In this case who does the rendering? React of Phaser? If the mentioned way is not the right one, could you suggest another? 回答1: There is a module for this on Github called react-phaser . Here is a

Uncaught TypeError: Cannot read property 'set' of undefined

让人想犯罪 __ 提交于 2019-12-25 17:37:41
问题 I've made a constructor (and put it above preload function) like this character = function(CharX,CharY,CharSpeed){ this.x = CharX ; this.y = CharY; this.speed = CharSpeed; this.AddSpriteSheet = function (SprX,SprY,key) { this.character = game.add.sprite(SprX,SprY,key);} }; Later in create function I added var Char1 = new character(game.world.width*0.5,game.world.height*0.5,5); Char1.AddSpriteSheet(game.world.width*0.5,game.world.height*0.5,'character'); Char1.anchor.set(50,50); Console reads

New state with Phaser

吃可爱长大的小学妹 提交于 2019-12-25 01:19:46
问题 I'm trying to switch state with a collision. So when the player hits another sprite it should switch state, but it doesn't.. First I'm declaring the player and the enterDoor sprites under create: : playerSprite = this.game.add.sprite(50, 1700, 'player-front'); player = new Player(playerSprite); this.game.physics.enable(player, Phaser.Physics.ARCADE); enterDoor = this.game.add.sprite(332, 830, 'player-back'); playerDoor = new Player(enterDoor); this.game.physics.enable(playerDoor, Phaser

Phaser + Typescript losing scope in update

a 夏天 提交于 2019-12-24 11:12:43
问题 I feel like I'm doing something wrong, but searching for Phaser + Typescript related scope issues I'm coming up with nothing (tons on JS 'this' / scope though - it doesn't seem to translate well). I'm trying to set up a Phaser.Game instance, which from my understanding takes a few callbacks (in my case, preload, create then update). Update gets called until the browser is closed. My issue is that inside update, I have no access to the variables inside the current class. Code: import { Player