phaser-framework

Tilemap Collisions don't work in Phaser

こ雲淡風輕ζ 提交于 2019-12-11 04:16:49
问题 I'm a complete newbie in Phaser, and I've been having this problem for the last couple of days. Basically, I want my player to collide with the CollisionsLayer in my .json tilemap, but it doesn't work and the player goes right through. I have tried multiple versions of Phaser and none of them seem to work. Here's my code: <!DOCTYPE html> <html> <head> <title>RPG Game</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.3.0/phaser.min.js"></script> </head> <body> <script> var

Passing a music object between states in a Phaser game engine

大兔子大兔子 提交于 2019-12-11 01:12:59
问题 My question is specific about Phaser game engine So I have a game with a few states and each state is defined like: var myGame = {}; myGame.Boot = function (game) { }; myGame.Boot.prototype = { init: function () { //some init }, create: function () { //this.scale.scaleMode this.state.start('Preloader'); } }; and a game is defined like: var game = new Phaser.Game(gameWidth, gameHeight, Phaser.AUTO, 'main'); game.state.add('Boot', myGame.Boot); game.state.add('Preloader', myGame.Preloader);

How to use a local font in Phaser 3?

点点圈 提交于 2019-12-10 16:47:20
问题 I have a font in a fonts/ directory. How do I load this into the game, then use it on a text object in my game? I haven't been able to find anything on using fonts in Phaser 3. 回答1: First use css to load your font(@fontface): <style media='screen' type='text/css'> @font-face { font-family: font1; src: url('media/yourfont.ttf'); font-weight:400; font-weight:normal; } </style> And then use a div to load your font: <div style="font-family:font1; position:absolute; left:-1000px; visibility:hidden

Phaser JS how to stop event Propagation(firing) from textButton.events.onInputDown event to game.input.onDown event?

狂风中的少年 提交于 2019-12-10 14:09:09
问题 Here is the JSFiddle . I have two events here. Is game.input.onDown which does some logic (generates particles in my example) Is textButton.events.onInputDown , where textButton is a Phaser.Text object instance, which does another logic. The problem is: when I click on my textButton both event are fired 1 and 2 . The question is, how to prevent event 1 from firing when I click on the textButton ? Part of code: ... //This event is fired on click anywhere event # 1 game.input.onDown.add

2D soft bodies: Gelly and moldable?

狂风中的少年 提交于 2019-12-10 12:31:25
问题 I am using Matter.js physics in an attempt to create soft bodies. I was able to create a body like this: However I am not sure if this is the "soft body" I want. It is true that this body is not entirely rigid and has that bouncy feel when it collides and gets dragged. I was looking for a body that shares similarities with a gelly. This image might visually help explaining the concept: I was wondering how these type of bodies can be made. Is it the same as the as matter.js soft body but with

UIWebview open URL in mobile safari using javascript

[亡魂溺海] 提交于 2019-12-10 10:45:52
问题 So I'm building an HTML5 game using phaser and I have a button that calls a URL in javascript like this: window.open("http://google.com", "_blank"); This works great on desktop opening in a new window, I'm also able to get it to open in the default browser on an android device via webview as well. But on iOS using a UIWebView in swift I'm using the following code func webView(webView: UIWebView!, shouldStartLoadWithRequest request: NSURLRequest!, navigationType: UIWebViewNavigationType) ->

Multiplayer game - synchronizing ball

折月煮酒 提交于 2019-12-08 07:07:06
问题 I'm developing a very simple game in HTML5 with the amazing phaser.io. The game is very simple: a 1vs1 volley game in 2D... Actually it is 'copy' of the great "pikachu volley"(http://imagenes.es.sftcdn.net/es/scrn/12000/12531/pikachu-volleyball-2.jpg). As I said, the game is very easy, I have: Player1 Player2 Static elements Ball And I have just to control: - Players movements - Ball movements(actually controlled by Arcade Physics) - Players-Ball collisions I made it just for fun, adding the

Make objects inside a group collide with themselves in Phaser.io?

时光总嘲笑我的痴心妄想 提交于 2019-12-07 20:17:55
问题 This question is regarding phaser.io. Can someone show me how to make objects inside a group collide with each other. Right now when i do, //board is the group and it has many elements //Floor is where all the elements fall to game.physics.arcade.collide(this.board, this.floor); All the elements inside the group stack on top of each other when they hit the floor at the same position. In other words the stack builds at one position, the latest one hiding the previous element and not upwards in

Use Haxe API classes explicitly

≡放荡痞女 提交于 2019-12-07 05:54:17
问题 I use Haxe targeting Javascript. I have a package (defined as an extern), " phaser ", that contains a Math class along with many others. I use import phaser.*; at the beginning of my files because I use many classes from this package and I don't want to prefix them all with phaser. . I would like to use the Math class from Haxe API, but if I try to use it (e.g Math.random() ), the compiler thinks I want to use phaser.Math and tells me there is no such function in it. Can I explicitly write

Make objects inside a group collide with themselves in Phaser.io?

大兔子大兔子 提交于 2019-12-06 13:03:16
This question is regarding phaser.io. Can someone show me how to make objects inside a group collide with each other. Right now when i do, //board is the group and it has many elements //Floor is where all the elements fall to game.physics.arcade.collide(this.board, this.floor); All the elements inside the group stack on top of each other when they hit the floor at the same position. In other words the stack builds at one position, the latest one hiding the previous element and not upwards in the sense one on top of another at a higher position. How can i make the stack build upwards? If you