I’d like to convert a game I ‘tinkered with,’ written for Phaser 2, to the latest - Phaser 3. It’s based on the Concentration game by Emanuele Feronato in “From null to full.” It didn’t get very far with the Phaser 3 framework!
game.state.add seems like a pretty direct instruction, but Phaser 3 says “Cannot read property ‘add’ of undefined” on line 184, which says “game.state.add(“PreloadAssets”, preloadAssets);”
How is that instruction implemented in Phaser 3? Better yet, is there a document I can reference about the changes between 2 and 3? I have a feeling there will be a lot more Uncaught TypeErrors and such as I go through the process of updating the game.
Yes, I’m a noob. There is a lot of material out there about writing code with Phaser 2. Phaser 3 is still young(ish), and it would be great to convert a lot of that P2 material to current P3 status. Your help will be appreciated! Thanks,
Thank you for the comments, tN. I have 2 parts to my reply to your reply:
Version Control. I’ve already wrestled with this one a bit. I have to keep my P2 files with a separate phaser.js file than the P3 files. It would be nice to get them all working off the same version; and,
Learning P3. I have found a lot of material on developing games with P2. If I could figure out how to convert those ideas to P3, it seems like a phantastic way to learn how to work with P3.
I might want to take on that kind of project after I get more familiar with Phaser. I just can’t say how long that’ll be!
Thanks again,
CB__
API of v3 is totally changed. Changing method names will not upgrade any v2 game to use v3.
You can use the game logic/idea described on v2 material to v3 but implementing those ideas in v3 would be almost always different than how it’s implemented in v2.
Take for example
states in v2 are changed to scenes. You can’t run multiple states in v2 but you can run multiple scenes in v3.
group in v3 is not same as group in v2. You can’t do nesting in v3. Same way you can’t addChild to any sprite in v3.
So, how you implement a game in v3 will be different than in v2.
It’s quite old post but here you can read what Phaser Dev’s say about converting.
Thanks for the pointers; I’ll definitely review them.
Yah, version control is some form of folder management. Reading your comments, I had another idea, in the webroot folder you could do assets/p2 & assets/p3 and just change the script src to the one you want to use.
Onward and upward!