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.1k
CircleCIとwercker
ryonext
3
1.3k
Other Decks in Programming
See All in Programming
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
14
6.6k
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
780
Performance Engineering for Everyone
elenatanasoiu
0
250
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
210
これからAgentCoreを触る方へトレンドはGatewayです
har1101
6
460
Creating Composable Callables in Contemporary C++
rollbear
0
180
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
290
dRuby over BLE
makicamel
2
400
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.9k
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
640
The NotImplementedError Problem in Ruby
koic
1
1.1k
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
150
Featured
See All Featured
エンジニアに許された特別な時間の終わり
watany
107
250k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
460
A better future with KSS
kneath
240
18k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
760
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Designing Experiences People Love
moore
143
24k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
270
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
550
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The agentic SEO stack - context over prompts
schlessera
0
840
Done Done
chrislema
186
16k
KATA
mclloyd
PRO
35
15k
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ਫ༵