Upgrade to Pro — share decks privately, control downloads, hide ads and more …

enchant.jsをRails上で動かした話

 enchant.jsをRails上で動かした話

2013/05/15 Shibuya.rbにて

ryonext

May 15, 2013
Tweet

More Decks by ryonext

Other Decks in Programming

Transcript

  1. 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ॲཧ͕ී௨ʹͰ͖Δ 13೥5݄15೔ਫ༵೔
  2. 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" 13೥5݄15೔ਫ༵೔
  3. 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 ͜ΕݺΜͰΔ 13೥5݄15೔ਫ༵೔
  4. assets pipelineམͱ݀͠ • ui.enchant.jsͷը૾͕ <IPTUOBNF><DVSSFOU@QBUI>ʹ ͋Δ͜ͱΛظ଴͍ͯ͠ΔͨΊɺ<IPTUOBNF>BTTFUT ʹը૾Λ഑ஔ͢Δassets pipelineͰ͸ಈ͔ͳ͔ ͬͨ •

    ͱΓ͋͑ͣpublic/ ʹը૾Λஔ͍ͯରॲ • CSSͷURLࢦఆΛimage-urlʹ͠ͳ͍ͱ͍͚ ͳ͍࿩ɺ͔ͳɾɾɾʢʁʣ 13೥5݄15೔ਫ༵೔
  5. jQueryϥΠϒϥϦ • είΞૹ৴ͷμΠΞϩά • jQuery UI ͷdialog • είΞૹ৴ޙͷ௨஌ •

    jQuery-Notify-bar • https://github.com/dknight/jQuery-Notify- bar 13೥5݄15೔ਫ༵೔