Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeCodeCamp Article Feedback #3

Open
gwilson2151 opened this issue May 31, 2019 · 0 comments
Open

FreeCodeCamp Article Feedback #3

gwilson2151 opened this issue May 31, 2019 · 0 comments

Comments

@gwilson2151
Copy link

Hi Mariya, thank you for writing the article at freecodecamp. I found it from the Latest Tutorials list on phaser.io. At the end of the article you mention any feedback is highly appreciated and this is the only place I could find to give feedback so here's mine.

The code formatting in the article text itself needs some fixing. I type everything in by hand when learning/practicing to better retain what I'm doing and it's quite difficult to do that with the way the code is formatted in the article now.

In GameScene's onClick and onFall functions a function is returned that's then registered as an event handler. I'd wrap the onClick and onFall calls in functions when registering the event handler rather than in the onClick or onFall calls themselves in case there are other times you need to invoke them in the future that you don't want wrapped.
Ex:

private onClick(star: Phaser.Physics.Arcade.Image):  void { /* etc... */ }
private onFall(star: Phaser.Physics.Arcade.Image):  void { /* etc... */ }

star.on('pointerdown', () => this.onClick(star), this);
this.physics.add.collider(star, this.sand, () => this.onFall(star), null, this);

In GameScene's onFall when the star is destroyed, after 100 ms it checks if more than two stars have been destroyed and ends the game. I converted that to a lambda function and it wasn't ending the game so there might be some this problems there (I haven't looked into it, probably shouldn't have made it a lambda function though). I moved the game ending check to the update() function to be closer to the rest of the game update operations, it's easier for me to reason about the class if the game ending check isn't stuck away in some event handler somewhere.

Again, thanks for the time you took to write the article. It's a good introduction to setting up a Phaser project with Typescript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant