trquoccuong Posted April 4, 2014 Share Posted April 4, 2014 Hi everybody. I am studying Ruby on Rails and I see Phaser have a gem for rails.But I didn't find any tutorial for use it.I make a mini tutorial for run Phase on rails .What you need :Rails Installer http://railsinstaller.org/ ( easy way to install Rails ) Any edictor like sublime text .v.v In this tutorial I use the tutorial by Alvin Ourrad and Richard Davey. http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-gameLet 's startCreate a new rails applicationrails new gamesGo to games folder by command linecd gamesCreate a controller for this game rails g controller star indexInstall Phaser to RailsAdd this code to Gemfile gem 'phaser-rails'Run on command line Bundle installOpen yourdir/games/app/assets/javascripts/application.html.erb and add this line //= require phaserNow I will copy all images on the tutorial to yourdir/games/app/assetsAfter that I will copy javascript code of that game to yourdir/games/app/views/star/index.html.erbRun the rails server Go to http://localhost:3000/star/index and try your games You can also upload that games to heroku like this http://blooming-fortress-2804.herokuapp.com/Sorry for my bad English Link to comment Share on other sites More sharing options...
george Posted April 4, 2014 Share Posted April 4, 2014 Hi trquoccuong, and all people who might follow this:Do not use a gem for every possible 'problem' or 'resource'. it's just your laziness and you won't get the latest update when you forget to update the gem explicitly (which you will forget for sure if you are one of the lazy heads). Do this instead:1. Fetch your latest version from phaser's github release page: https://github.com/photonstorm/phaser/releases2. Put the file phaser.min.js or phaser.js inside your asset folder in assets/javascripts/ and include it within your application.js which is easy with the support of the integrated asset pipeline. You could also create a folder 'lib' where you place all your external files and use a require_tree or a index.js file (for ordered require statements) inside the lib folder.//= require ./phaser.min.jsThat's it. There is nothing more in the phaser-rails gem just look in the repository of the gem:https://github.com/meinside/phaser-rails/tree/master/vendor/assets/javascripts You get used to it after the second time you do it- believe me. It's should be obvious, that I hate the 'gem for everything' thinking- but I love rails so much! By the way: I think this topic is rather off-topic, as this problem is related to ANY library you want to include in rails. It's not special to phaser. But maybe you got somebody to look into rails in this forum- so it's a win! Anyway trquoccuong. Have fun with rails & phaser. Two things that changed my life for the better Regards George Tilde and trquoccuong 2 Link to comment Share on other sites More sharing options...
David Posted April 5, 2014 Share Posted April 5, 2014 @George I agree with the sentiment. But rather than manually copy the library over from the git repo, I'd highly recommend just using bower. All it takes to get phaser into your project is bower install phaser-official David 1 Link to comment Share on other sites More sharing options...
ylluminarious Posted August 11, 2015 Share Posted August 11, 2015 If you folks are interested in working with Ruby and Phaser, you might like the opal-phaser gem, which allows you to write Phaser games in Ruby. Link to comment Share on other sites More sharing options...
Raiper34 Posted August 11, 2015 Share Posted August 11, 2015 Can I ask, what is advantage of this? Why to use it? Link to comment Share on other sites More sharing options...
ylluminarious Posted August 11, 2015 Share Posted August 11, 2015 @Raiper34 You mean with phaser-rails or opal-phaser? Link to comment Share on other sites More sharing options...
Recommended Posts