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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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.1k
CircleCIとwercker
ryonext
3
1.3k
Other Decks in Programming
See All in Programming
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
400
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.1k
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
140
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
340
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
330
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
JavaDoc 再入門
nagise
1
340
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.1k
TAKTでAI駆動開発の品質を設計する
j5ik2o
6
1.3k
The NotImplementedError Problem in Ruby
koic
1
780
Contextとはなにか
chiroruxx
1
320
Featured
See All Featured
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Writing Fast Ruby
sferik
630
63k
Un-Boring Meetings
codingconduct
0
310
A better future with KSS
kneath
240
18k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
The Limits of Empathy - UXLibs8
cassininazir
1
360
The SEO identity crisis: Don't let AI make you average
varn
0
490
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
KATA
mclloyd
PRO
35
15k
Everyday Curiosity
cassininazir
0
230
Faster Mobile Websites
deanohume
310
31k
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ਫ༵