Jump to content

Phaser on rails


trquoccuong
 Share

Recommended Posts

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 :D.

What you need :

  1. Rails Installer http://railsinstaller.org/ ( easy way to install Rails :D)
  2. Any edictor like sublime text .v.v
  3. In this tutorial I use the tutorial by Alvin Ourrad and Richard Davey. http://www.photonstorm.com/phaser/tutorial-making-your-first-phaser-game

Let 's start

  • Create a new rails application
rails new games
  • Go to games folder by command line
cd games
  • Create a controller for this game :D
rails g controller star index
  • Install Phaser to Rails
Add 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 phaser

 

Link to comment
Share on other sites

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/releases

2. 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.js

That'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

Link to comment
Share on other sites

  • 1 year later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...