Search the Community
Showing results for tags 'rails'.
-
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 start Create 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
-
Hello! I need some serious help ASAP! We're trying to develop a game using Phaser for our final project, but we can not figure out how to do this on Rails! I've tried using Rails, Phaser, and RequireJS. I've tried using Rails and the Phaser Rails gem. I do not understand how these modules communicate with one another. So far, my files are set up with RequireJS. I realize this is overkill because Rails has the Asset Pipeline, but it's already set up so we're going to have to make RequireJS work. My file structure looks like this: app assets bower_components > phaser-official images javascripts > modules > factories > states > units > CarouselGame.js > application.js > runtime.js stylesheets controllers helpers mailers models views In my runtime.js file, I have: requirejs.config({paths: {Phaser: 'bower_components/phaser-official/build/phaser'}});require(['app/assets/javascripts/modules/CarouselGame','app/assets/javascripts/modules/states/Boot','app/assets/javascripts/modules/states/Preload','app/assets/javascripts/modules/states/Oaktree','app/assets/javascripts/modules/states/Stream','app/assets/javascripts/modules/states/Minimenu','app/assets/javascripts/modules/states/Minigame','app/assets/javascripts/modules/states/EndDemo'],function (CarouselGame, BootState, PreloadState, OaktreeState, StreamState, MinimenuState, MinigameState, EndDemoState) {var game = new PhaserGame(640, 480);game.state.add('Boot', BootState);game.state.add('Preload', PreloadState);game.state.add('Oaktree', OaktreeState);game.state.add('Stream', StreamState);game.state.add('Minimenu', MinimenuState);game.state.add('Minigame', MinigameState);game.state.add('EndDemo', EndDemoState);game.state.start('Boot');});In my CarouselGame.js file, I have this: define(['CarouselGame','modules/extensions/','modules/units/backgrounds/oaktree.jpg','modules/units/backgrounds/stream.jpg','modules/units/backgrounds/temp_minigamebackground.png','modules/units/music/Firefly.mp3','modules/units/sounds/firefly_surprise.mp3','modules/factories/firefly'],function (Phaser) {var PhaserGame = function (w, h) {return new Phaser.Game(w, h, Phaser.AUTO);};return PhaserGame;});Right now, we keep getting the following errors: 1. Uncaught Error: Load timeout for modules: applicationhttp://requirejs.org/docs/errors.html#timeoutmakeError @ require.js:167checkLoaded @ require.js:693(anonymous function) @ require.js:7142. require.js:167 Uncaught Error: Mismatched anonymous define() module: function (Phaser) {var PhaserGame = function (w, h) {return new Phaser.Game(w, h, Phaser.AUTO);};return PhaserGame;}http://requirejs.org/docs/errors.html#mismatchmakeError @ require.js:167intakeDefines @ require.js:1240localRequire @ require.js:1422requirejs @ require.js:1758req.config @ require.js:1766(anonymous function) @ runtime.js?body=1:13. require.js:167 Uncaught Error: Mismatched anonymous define() module: function () {/*** FireFly defined*/var FireFly = function (game, x, y) {Phaser.Sprite.call(this, game, x, y, 'firefly');game.physics.enable(this, Phaser.Physics.ARCADE);this.body.collideWorldBounds = true;game.physics.arcade.velocityFromRotation(game.rnd.angle(), 500, this.body.velocity);};/*** FireFly instance creation.*/FireFly.prototype = Object.create(Phaser.Sprite.prototype);FireFly.prototype.constructor = FireFly;FireFly.prototype.update = function(){if(Math.ceil(Math.random() * 100) < 25){game.physics.arcade.velocityFromRotation(this.angle + game.rnd.integerInRange(-60, 60), 500, this.body.velocity);}};/*** return the created FireFly object.*/return FireFly;}http://requirejs.org/docs/errors.html#mismatchmakeError @ require.js:167intakeDefines @ require.js:1240localRequire @ require.js:1422requirejs @ require.js:1758req.config @ require.js:1766(anonymous function) @ application.js:118594. require.js:1919 GET http://localhost:3000/assets/bower_components/phaser-official/build/phaser.js req.load @ require.js:1919context.load @ require.js:1660Module.load @ require.js:829Module.fetch @ require.js:819Module.check @ require.js:849Module.enable @ require.js:1162context.enable @ require.js:1532(anonymous function) @ require.js:1147(anonymous function) @ require.js:133each @ require.js:58Module.enable @ require.js:1099Module.init @ require.js:783callGetModule @ require.js:1189context.completeLoad @ require.js:1565context.onScriptLoad @ require.js:16925. require.js:167 Uncaught Error: Script error for: Phaserhttp://requirejs.org/docs/errors.html#scripterrorCould someone please help me figure this out?