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
280
TwitterのList編集しやすいやつ作った
ryonext
0
1.8k
validationについて
ryonext
1
860
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
「人を評価する AI」の設計と実装
ryoyanara
0
210
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
220
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.9k
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.8k
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
660
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
230
これって Effect でできたのでは? / TSKaigi Mashup Kansai #2
susisu
0
250
引き算の組織 ― アウトカムとAIに全振りするために辞めたこと ― / Organization by Subtraction
hirokiyamamoto14
PRO
0
250
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
320
5分で問診!Composer セキュリティ健康診断
codmoninc
0
1.1k
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
700
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
160
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
5.9k
Chasing Engaging Ingredients in Design
codingconduct
0
280
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Agile that works and the tools we love
rasmusluckow
331
22k
Everyday Curiosity
cassininazir
0
290
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
How to Talk to Developers About Accessibility
jct
2
520
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
710
sira's awesome portfolio website redesign presentation
elsirapls
0
330
Darren the Foodie - Storyboard
khoart
PRO
3
3.7k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
800
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ਫ༵