Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
enchant.jsをRails上で動かした話
Search
ryonext
May 15, 2013
Programming
7.3k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
enchant.jsをRails上で動かした話
2013/05/15 Shibuya.rbにて
ryonext
May 15, 2013
More Decks by ryonext
See All by ryonext
AWS Lambda の Ruby 対応
ryonext
0
270
TwitterのList編集しやすいやつ作った
ryonext
0
1.8k
validationについて
ryonext
1
850
AWS Lambda と API GatewayでRails使わずに済んだ話
ryonext
8
4.4k
capistrano-bundle_rsync使ったらオートスケールが高速化した話
ryonext
8
2.6k
PumaとUnicornで最近自分が理解したこと
ryonext
13
9.6k
Hubot事例
ryonext
1
1.7k
Redisでバッチ処理を冗長化しつつ排他制御
ryonext
0
2.2k
CircleCIとwercker
ryonext
3
1.3k
Other Decks in Programming
See All in Programming
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
290
Android CLI
fornewid
0
190
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
2
1.2k
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
180
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
110
Foundation Models frameworkで画像分析
ryodeveloper
1
160
What's New in Android 2026
veronikapj
0
230
AIエージェントで 変わるAndroid開発環境
takahirom
2
740
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
410
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
190
yield再入門 #phpcon
o0h
PRO
0
820
エンジニアにデザインハーネスを 〜デザインプロセスを規定するためのハーネス〜 / Design harness from an engineer's perspective
rkaga
2
1.8k
Featured
See All Featured
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.7k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
260
Producing Creativity
orderedlist
PRO
348
40k
Code Review Best Practice
trishagee
74
20k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
What's in a price? How to price your products and services
michaelherold
247
13k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
Are puppies a ranking factor?
jonoalderson
1
3.7k
Transcript
enchant.jsΛRails্Ͱ ಈ͔ͨ͠ @ryonext 135݄15ਫ༵
ࣗݾհ • Twitter ID: ryonext • ࣄͰRailsͬͯ·͢ɻ 135݄15ਫ༵
͜Εʹ͍ͭͯ͠·͢ http://bearsheaven.herokuapp.com/ 135݄15ਫ༵
enchant.js • ήʔϜ࡞Γʹ͍ͨjsϑϨʔϜϫʔΫ • http://enchantjs.com/ja/ 135݄15ਫ༵
jsdo.it http://jsdo.it/ 135݄15ਫ༵
ڈ࡞ͬͨήʔϜ 135݄15ਫ༵
Rails্Ͱಈ͔ͯ͠είΞอ ଘͱ͔ͯ͠ΈΑ͏ͱࢥͬͨ 135݄15ਫ༵
• enchant.jsͷίʔυ͔Βී௨ͷjsDOMཁૉ ͷૢ࡞͕Ͱ͖ΔͷͰՄೳ ࣮ࡍͰ͖Δͷ͔ʁ 135݄15ਫ༵
109 # ήʔϜຖϑϨʔϜͷॲཧ 110 game.rootScene.addEventListener Event.ENTER_FRAME, -> 111 #ϠϥϨνϟολʁ 112
if player.status is STATUS_CRY 113 if player.y > CHARACTER_Y && gameOver is false 114 gameOver = true 115 sendScore(game.score, difficult.text, game.max_magnification) ࢮΜͩͱ͖ͷॲཧ͜ͷลͰɺ enchant.jsͱؔͳ͍jsॲཧ͕ී௨ʹͰ͖Δ 135݄15ਫ༵
• είΞొͷControllerͱModelΛ࡞ͬͯɺjs ͔ΒݺΜͰ͋͛ΕOK 135݄15ਫ༵
JSଆ 13 postScore = (score, difficulty, name, magnification) -> 14
$.ajax 15 url: "/games", 16 type: 'POST', 17 dataType: 'json', 18 timeout: 1000, 19 data: { 20 score: { 21 name: name, 22 point: score, 23 difficulty: difficulty, 24 magnification: magnification 25 } 26 } 27 success: -> 28 $.notifyBar 29 html: "success!", 30 delay: 2000, 31 animationSpeed: "normal" 135݄15ਫ༵
Railsଆ 1 class GamesController < ApplicationController 2 def new 3
render :layout => false 4 end 5 6 def create 7 score = Score.new(params[:score]) 8 score.save! 9 render json: {status: true} 10 end 11 12 def index 13 @scores = Score.order("point desc").limit(10) 14 end 15 end ͜ΕݺΜͰΔ 135݄15ਫ༵
ଞʹͬͨ͜ͱ • CoffeeScriptԽ • assets pipelineରԠ 135݄15ਫ༵
CoffeeScriptԽ • js ⇔ coffeeͷ૬ޓมαΠτΛར༻ • http://js2coffee.org/ • ͨͩ͠ɺذͷҰ෦Λਖ਼͘͠มͯ͘͠Εͳ ͔ͬͨͨΊॻ͖ͳ͓͢ඞཁ͕͋ͬͨɻ
135݄15ਫ༵
assets pipelineରԠ • enchant.jsͱui.enchantjsΛϓϩδΣΫτʹೖ Εͯɺapplication.jsʹهೖ • //= require enchant //=
require ui.enchant 135݄15ਫ༵
assets pipelineམͱ݀͠ • ui.enchant.jsͷը૾͕ <IPTUOBNF><DVSSFOU@QBUI>ʹ ͋Δ͜ͱΛظ͍ͯ͠ΔͨΊɺ<IPTUOBNF>BTTFUT ʹը૾Λஔ͢Δassets pipelineͰಈ͔ͳ͔ ͬͨ •
ͱΓ͋͑ͣpublic/ ʹը૾Λஔ͍ͯରॲ • CSSͷURLࢦఆΛimage-urlʹ͠ͳ͍ͱ͍͚ ͳ͍ɺ͔ͳɾɾɾʢʁʣ 135݄15ਫ༵
assets pipelineམͱ݀͠2 • enchant.jsಡΈࠐΉͱήʔϜ͕࢝Ίͬͯ͠ ·͏ͨΊɺήʔϜΛݟ͍ͤͨϖʔδͰͷΈಡ ΈࠐΈ͍ͨ(assets piplineΛ͚Δʣ • config/environments/production.rb •
config.assets.precompile += %w( games.js ) 135݄15ਫ༵
ͦͷ΄͔ • tutorialϖʔδͷ࡞ • ੩తཁૉ͔͠ͳ͍͚Ͳͦͷ··RailsͰ࡞ • ຊޠΘͳ͍Α͏ʹͯ͠Έͨ 135݄15ਫ༵
੩తϖʔδ • ࣄͷίʔυ͕haml͚ͬͨͲ naoya ͞Μ ͷهࣄͰslimͬͯΔࣄ͕ॻ͍ͯ͋ͬͨΜ ͰझຯͷίʔυͳΒͬͺΓslimͰ͍͍͔ ͳɺͱࢥͬͨΓɻ • ࡢࠓͷࣗ༻WebΞϓϦέʔγϣϯͻͳܗ
- naoyaͷͯͳμΠΞϦʔ http:// d.hatena.ne.jp/naoya/20130503/1367581629 135݄15ਫ༵
webfont • είΞͷϑΥϯτɺWebϑΥϯτͰ͜ͷϑΝ ϛίϯͬΆ͍ϑΥϯτ↓͍͔͚ͨͬͨͲ WebͰ͏ʹॏ͍(1M over)ͷͰஅ೦ • 8×8υοτຊޠϑΥϯτʮඒ࡙ϑΥϯτʯ http://www.geocities.jp/littlimi/misaki.htm 135݄15ਫ༵
jQueryϥΠϒϥϦ • είΞૹ৴ͷμΠΞϩά • jQuery UI ͷdialog • είΞૹ৴ޙͷ௨ •
jQuery-Notify-bar • https://github.com/dknight/jQuery-Notify- bar 135݄15ਫ༵
Εͯͳ͍͜ͱ • ηΩϡϦςΟपΓͳʹͯ͠ͳ͍ͷͰ࣮ε ίΞͷPOSTͷURLʹ͋Ε͢Εɾɾɾ • ςετॻ͍ͯͳ͍ • jsͰॻ͍ͨίʔυ͕ͦͦςετॻ͚Δ Α͏ͳઃܭʹͳͬͯͳ͍ •
WiiUରԠ 135݄15ਫ༵
Ҏ্ 135݄15ਫ༵