playif / play_phaser Goto Github PK
View Code? Open in Web Editor NEWA Dart port for Phaser 2D game engine.
License: MIT License
A Dart port for Phaser 2D game engine.
License: MIT License
I started seeing this error on the console log when I upgraded to 11.0 - I see it in 11.1 as well.
Class Menu extends the Phaser.State class. The log entry shows up when I click on a Phaser.Button object. Nothing seems broken, the behavior is working, it just logs exceptions.
Exception: Class 'Menu' has no instance method '<'.
NoSuchMethodError: method not found: '<'
Receiver: Instance of 'Menu'
Arguments: [1] package:play_phaser/gameobjects/image.dart:896Image.set:frame package:play_phaser/gameobjects/image.dart:896Button.setState package:play_phaser/gameobjects/button.dart:574Button.onInputOverHandler package:play_phaser/gameobjects/button.dart:450SignalBinding.execute package:play_phaser/core/signal_binding.dart:40Signal.dispatch package:play_phaser/core/core_signal.dart:160InputHandler._pointerOverHandler@290914109 package:play_phaser/input/input_handler.dart:818Pointer.processInteractiveObjects package:play_phaser/input/pointer.dart:652Pointer.move package:play_phaser/input/pointer.dart:526Mouse.onMouseMove package:play_phaser/input/mouse.dart:397Mouse. package:play_phaser/input/mouse.dart:301
Exception: Class 'Menu' has no instance method '<'.
NoSuchMethodError: method not found: '<'
Receiver: Instance of 'Menu'
Arguments: [1]
This seems to be caused somewhere by tweens when trying to access a variable using reflection I think. This is rather urgent because my Ludum Dare game is unplayable right now because of that
edit: it seems that getters and setters are not supported with dart2js' mirrors?
Game game = new Game(window.innerWidth, window.innerHeight, WEBGL, '', new Main(), true);
There is no difference between true or false, when i checked it in Main.create it is always false.
I took a look at Game constructor, mistake is probably there. :) ๐
I have a function like this that plays a sound and I want it to return only once the sound stops so I am trying to use a Completer
.
Future<bool> playAttackSound(AttackType type)
{
Sound s;
Completer comp = new Completer();
switch (type) {
//init s based on type
...
}
s.onStop.addOnce((Sound foo) => comp.complete(true));
s.play();
return comp.future;
}
}
But...when I run my game once the sound plays I get these errors.
Closure call with mismatched arguments: function 'call'
NoSuchMethodError: incorrect number of arguments passed to method named 'call'
Receiver: Closure: (Sound) => dynamic
Tried calling: call(Instance of 'Sound', "")
Found: call(foo)
What's going on here?
When using the ninja tileset along with AABB, the full tile(the tile with the ID of 1) returns an error stating that there are too many parameters for the function, projAABB_Full. Looking in the lib/physics/ninja/aabb.dart file, I noticed that the function projAABB_Full was missing the 'Tile t' parameter that even the comment documentation shows. While technically the function does not need that parameter, whatever calls it passes it, which means there will be an error whenever it is run. I was able to resolve the problem easily by simply adding that parameter.
I recently decided to test trying to run the dart.js output of my project by setting up a site via Github pages. Unfortunately I get this error in the browser console and the canvas I try to insert via code is not there
Uncaught TypeError: Cannot read property 'append$1' of null
My site for it is here so if you open devtools in Chrome for example you can see a stack trace, with source-maps. Sadly I think I may have accidentally borked something with the source map because the links in the dev tools don't quite seem to link to what they say they do in some cases but it's still fairly ok.
I was trying to debug this issue with a friend and they mentioned that one slight issue in the Phaser code here as well is the Game constructor's param parent
is typed String
but really the code within accepts String
or Element
or something like that, so that's a little misleading.
Oh and another thing, when I use Point
s in my code I get a warning in DartEditor about how phaser.dart (lib file) implicitly hides Point from math package. So I think your library file import of dart:math
should read like import 'dart:math' hide Point;
It may not be an issue in my case with what I've been doing but to quote my friend when we were talking about my issue....if you don't hide things like so "Dart has to guess what you mean and may guess wrong".
This error is coming from Sprite.update crop.:
//this._crop = Rectangle.clone(this.cropRect, this._crop);
this._crop.x += this._frame.x;
this._crop is null. If you un-rem the lines, there is no Rectangle.cone method.
It looks like Phaser.Rectangle.clone = function (a, output) {
isn't getting ported.
So I posted this on SO but I guess I have realised it's maybe a bit too localised for people there to care to give their time to help, my question is as the issue title says. My SO question is here: http://stackoverflow.com/questions/28264727/how-to-pass-values-to-phaser-dart-port-state-init-function
If you don't feel like reading the whole thing there is something of a TL;DR at the end...which explains the error I am running into which I understand the cause of but cannot solve.
I have a Group of entities and I use sort on it, like this
entities.sort('y', Group.SORT_ASCENDING);
But I get the following exception
Breaking on exception: Class 'PlayerEntity' has no instance method '[]'.
Might be broken due to a change in a newer version of Dart, the code in the library does not look wrong.
Hi, the "analyzeAll" issue still occurs for me even when I upgraded to the new 0.12.2 package. First I thought it was a corrupt cache on my part, but after I cleared it, removed the package and tried it again, the same error appears. I'm using Dart SDK 1.8.3 stable release.
I understand that in the example of the readme you made a subclass of State, but when I attempt to separate the subclass into a different file, the error of "Exception: type 'TestState' is not a subtype of type 'State' of 'state'" comes up. I do not know if that's intentional or if it's because of my limited knowledge of dart.
main() {
Game game = new Game(800, 480, WEBGL, '', new TestState());
}
class TestState extends State {
//the methods go here
}
(Test.dart)
import 'TestState.dart';
main() {
Game game = new Game(800, 480, WEBGL, '', new basic_01_load_an_image());
}
(TestState.dart)
class TestState extends State {
//the methods go here
}
This is what's in master right now:
dependencies:
browser: ">=0.10.0+2 <0.11.0"
uuid: ">=0.3.2 < 0.4.0"
play_pixi:
path: ../play_pixi
Won't work unless for some reason a package user has checked out play_pixi locally.
I get this error when calling "scale.setScreenSize(true);" in ScaleManager.
This is the dart code that raises an exception:
this._check.cancel();
In the original, no exception is raised here when this_check is null -
Phaser.js does this:
clearInterval(this._check);
Thanks,
Bruce
Certain operations could be simplified further by adding operators to the Point class that use numbers rather than points
i.e
myPoint * new Point(2.0, 2.0); // without
myPoint * 2.0; // with
If followiing the installation instruction on https://pub.dartlang.org/packages/play_phaser you end in Unrecognized dart2js option "analyzeAll" error.
Dart SDK version 1.8.0
I am on Win7 running latest Dart version and I have my dart file as below
import 'package:play_phaser/phaser.dart';
class PhaserTest
{
void main()
{
Game game = new Game(800, 600, AUTO, 'output');
State blah = new MyState();
game.state.add('state1', blah);
game.state.start('state1');
}
}
//Phaser basics_1 example
class MyState extends State
{
Sprite image;
preload() {
// You can fill the preloader with as many assets as your game requires
// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.
// The second parameter is the URL of the image (relative)
game.load.image('car', 'bunny.png');
}
create() {
// This creates a simple sprite that is using our loaded image and
// displays it on-screen
image = game.add.sprite(game.world.centerX, game.world.centerY, 'car');
// Moves the image anchor to the middle, so it centers inside the game properly
image.anchor.set(0.5);
image.scale.set(2);
}
update() {
image.angle += 1;
}
}
When I click my index.html to "Run in Dartium" and it loads, there is nothing but a blank tab...I don't understand, have I really done something wrong here or is something broken? :( I mean really, my code is just like your first example. To clarify, bunny.png IS in the web directory of the same project and output is a div in the body of my html.
Create method
game.world.scale.set(1.05, 1.05);
game.physics.startSystem(Physics.ARCADE);
somewhere in constructor of class which extends Sprite
game.physics.enable(this, Physics.ARCADE, true);
Results in the following https://gfycat.com/AggressiveBasicDungbeetle
A bit of self promotion here, but I would love to see the tween engine put to use in a project like this:
https://github.com/xaguzman/tween-engine-dart
would you be up for adding it?
****************************************************************
* WARNING: dart:mirrors support in dart2js is experimental,
* and not recommended.
* This implementation of mirrors is incomplete,
* and often greatly increases the size of the generated
* JavaScript code.
*
* Your app imports dart:mirrors via:
* ef-client.dart => package:play_phaser => dart:mirrors
*
* You can disable this message by using the --enable-experimental-mirrors
* command-line flag.
*
* To learn what to do next, please visit:
* http://dartlang.org/dart2js-reflection
****************************************************************
[Warning from Dart2JS]:
2530 methods retained for use by dart:mirrors out of 4921 total methods (51%)
is this really needed? Could it potentially be removed?
Posted a question on HTML5 gamedev forum but unfortunately the one person trying to help so far doesn't have experience with Dart...so I'm wondering if anyone reading this here might know if there's a way to achieve this.
Since I like Phaser but I'm not really big on Javascript nor CoffeeScript but really like Dart, I decided to give this a try. I'm having an issue where all animations play super fast, no matter what framerate I pass as a parameter. Is this a known issue? If not, I could provide you some more information
p.s: Will support for play_phaser stay consistent in the future as new Phaser releases come out, or is this just like a side project that might be dropped at any given time?
The documentation link on the right-side of the page (https://pub.dartlang.org/packages/play_phaser) is broken.
The ugly exception is gone but calling the sort method now renders the scene completely black.
entities.sort('y', Group.SORT_ASCENDING);
I'm adding two sprites to that group, I find it kind of odd that it would render the whole scene black
easy step to reproduce:
//create shadow
this.shadow = game.add.sprite(x, y, 'tank', 'shadow');
//then the tank body
this.tank = game.add.sprite(x, y, 'tank', 'tank1');
//attach shadow to tank, so they will move togheder
tank.addChild(shadow);
//now activate physics!
game.physics.enable(tank, Physics.ARCADE, false); // <-- it break the engine!
Game class constructor parent parameter not working.
:
<body>
<div id="aaaaa"></div>
</body>
:
void main() {
Game game = new Game(800, 450, WEBGL, 'aaaaa', new SampleState());
}
:
Canvas is appended body bottom.
:
<body>
<div id="aaaaa"></div>
<canvas ... ></canvas>
</body>
:
Thank you.
In Dart, if (Null)
and if (!Null)
cause type errors.
ScaleManager
depends on !isFullScreen
evaluating like isFullScreen == Null
in at least one line of code.
If the following lines of code are placed in the preload() method for a State implementer:
game.scale.scaleMode = ScaleManager.SHOW_ALL;
game.scale.setScreenSize(false);
A type error occurs at line 1108 in scale_manager.dart:
} else if (!this.isFullScreen) {
isFullScreen
should probably be initialized to false
.
The timer crashes with a type error when triggered if the given delay is an integer.
The property Timer._newTick should be a num or the calculated value should be converted to a double when updating it. Or the Timer.add() should take a double and not a num.
To reproduce:
timer = game.time.create();
TimerEvent te = timer.add(1000, () => print("timer called"));
This will crash after 1000ms with: type 'int' is not a subtype of type 'double' of 'value'.
In a class which extends Sprite
animations.play('run-down');
The animation doesn't immediately replace the old one (probably waits for the last frame of the old animation to end)
Hello,
I tried your example basic_02_click_on_an_image, click makes nothing .
Other thing:
create(){
image = mygame.add.sprite(mygame.world.centerX, mygame.world.centerY, 'man');
image.anchor.set(0.5,0.5);
image.inputEnabled = true;
image.events.onInputDown.add(listener);
texty = mygame.add.text(250, 16,"click on picture", new TextStyle(fill:'#ea4c89'));
texty.setText("I changed");
}
setText("I changed") doesnt. (refresh text or on console)
Other thing:
create(){
image = mygame.add.sprite(mygame.world.centerX, mygame.world.centerY, 'man');
image.anchor.set(0.5,0.5);
image.inputEnabled = true;
image.events.onInputDown.add(listener);
texty = mygame.add.text(250, 16,"click on picture", new TextStyle(fill:'#ea4c89'));
}
when a use a listener
listener(Sprite s, Pointer p){
counter++;
texty.setText("change");
texty.text= "change $counter";
Dom.window.console.log(texty.text);
}
Text change only I use setTex() and texty.text both.
If I use only setText("changed") or texty.text = "changed", it doesnt
remark: when I look the console texty.text change but no refresh the picture, but setText() make nothing.
I hope you understand and helped you.
Gi
Take a look at that
num get centerY => this.x + this.halfHeight;
Should be this.y
Hi, I am running the example ninja_AABB_vs_AABB, when the untinted block collides into the tinted block from the left, the tinted block pushes back, which doesn't look right. When colliding from the right side it works just fine
Hi, the input events for Text objects seem to be broken
example:
create() {
TextStyle style = new TextStyle(font:'100px Arial', fill: 'white');
Text play = game.add.text(0, game.world.centerY, 'Play', style);
play.inputEnabled = true;
//this doesn't work
play.events.onInputDown.add((a, b) {
print("play");
}, 1);
Sprite sprite = game.add.sprite(game.world.centerX + 64, game.world.centerY, 'grass');
sprite.inputEnabled = true;
//this does
sprite.events.onInputDown.add((a, b) {
print("grass");
}, 1);
}
Thanks for this project it's really helpful! Would it possible to update to the latest Phaser version?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.