{"id":2018,"date":"2012-09-21T08:17:37","date_gmt":"2012-09-20T23:17:37","guid":{"rendered":"http:\/\/www.lancard.com\/blog\/?p=2018"},"modified":"2025-03-12T11:29:49","modified_gmt":"2025-03-12T02:29:49","slug":"mobiruby%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e4%bd%9c%e3%82%8a%e3%81%be%e3%81%97%e3%81%9f%e5%8b%95%e7%94%bb%e4%bb%98","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2012\/09\/21\/mobiruby%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e4%bd%9c%e3%82%8a%e3%81%be%e3%81%97%e3%81%9f%e5%8b%95%e7%94%bb%e4%bb%98\/","title":{"rendered":"MobiRuby\u306e\u30b5\u30f3\u30d7\u30eb\u4f5c\u308a\u307e\u3057\u305f(\u52d5\u753b\u4ed8)"},"content":{"rendered":"<p>\u65b0\u7740\u60c5\u5831\u3001<a href=\"http:\/\/www.lancard.com\/news\/archives\/22\" target=\"_blank\">\u300e9\/22(\u571f) Ruby\u30d3\u30b8\u30cd\u30b9\u30fb\u30b3\u30e2\u30f3\u30ba\u304c\u300c\u3010RBC Tech Saturday\u3011MobiRuby\u3067iOS\u30a2\u30d7\u30ea\u3092\u3064\u304f\u308d\u3046 \uff5e\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u958b\u767a\u306bmruby\u304c\u3084\u3063\u3066\u304d\u305f\uff5e\u300d\u3092\u958b\u50ac\u3057\u307e\u3059\u300f<\/a>\u3067\u304a\u77e5\u3089\u305b\u3057\u3066\u304a\u308a\u307e\u3059\u3068\u304a\u308a\u3001\u660e\u65e5\u3001\u5f15\u8d8a\u3057\u524d\u306e\u5f0a\u793e\u65b0\u30aa\u30d5\u30a3\u30b9\u3067RBC\u306eMobiRuby\u30a4\u30d9\u30f3\u30c8\u3092\u958b\u50ac\u3057\u307e\u3059\u3002\u307e\u3060\u53c2\u52a0\u67a0\u3042\u308a\u307e\u3059\u3002\u305c\u3072\uff01<\/p>\n<p>\u3055\u3066\u3001\u672c\u984c\u3002\u3053\u306e\u30a4\u30d9\u30f3\u30c8\u7528\u306b\u7c21\u5358\u306a\u30b5\u30f3\u30d7\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u8d77\u52d5\u3059\u308b\u3068BGM\u3092\u6f14\u594f\u3001\u4e2d\u592e\u306b\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u3092\u8868\u793a\u3002\u753b\u9762\u3092\u30bf\u30c3\u30c1\u3059\u308b\u3068\u52b9\u679c\u97f3\u3092\u306a\u3089\u3057\u3066\u30bf\u30c3\u30c1\u5148\u306b\u30ad\u30e3\u30e9\u30af\u30bf\u30fc\u304c\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3067\u79fb\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u518d\u751f\u3059\u308b\u3068\u97f3\u304c\u3067\u307e\u3059\u3002<br \/>\n<iframe loading=\"lazy\" width=\"420\" height=\"315\" src=\"http:\/\/www.youtube.com\/embed\/xEvNtUROOgM\" frameborder=\"0\" allowfullscreen><\/iframe><br \/>\nBGM\u3068\u52b9\u679c\u97f3\u306f\u30e6\u30a6\u30e9\u30dc8bit\u30b5\u30a6\u30f3\u30c9\u5de5\u623f\u306e\u3082\u306e\u3092\u4f7f\u7528\u3055\u305b\u3066\u3044\u305f\u3060\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9(roundnyaabe.rb)\u3092\u8cbc\u308a\u307e\u3059\u3002<br \/>\nsamegame\u7528\u306eext.rb\u3092\u4f7f\u308f\u305b\u3066\u3082\u3089\u3063\u3066\u3044\u308b\u306e\u3067\u982d\u3067require\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre lang=\"ruby\">\r\nrequire 'ext'\r\n\r\ndef CGPointMake(x, y)\r\n    point = Cocoa::Struct::CGPoint.new\r\n    point[:x], point[:y] = x.to_f, y.to_f\r\n    return point\r\nend\r\n\r\nclass Cocoa::MyViewController < Cocoa::UIViewController\r\n\r\n    define C::Void, :viewDidLoad do\r\n        #\u80cc\u666f(\u9ed2)\r\n        screen_rect = Cocoa::UIScreen._mainScreen._bounds\r\n        background_view = Cocoa::UIView._alloc._initWithFrame(screen_rect)\r\n        background_view._setBackgroundColor(Cocoa::UIColor._blackColor)\r\n        self._view._addSubview(background_view)\r\n    \r\n        #\u306b\u3083\u301c\u3076\u767b\u5834\r\n        @nyaabe_image_view = Cocoa::UIImageView._alloc._initWithFrame(CGRectMake(0, 0, 50, 50))\r\n        @nyaabe_image_view._setImage(Cocoa::UIImage._imageNamed(_S(\"nyaabe_iphone.png\")))\r\n        point = Cocoa::Struct::CGPoint.new\r\n        point[:x] = (screen_rect[:size][:width] \/ 2).to_f\r\n        point[:y] = (screen_rect[:size][:height] \/ 2).to_f\r\n        @nyaabe_image_view._setCenter(point)\r\n        self._view._addSubview(@nyaabe_image_view)\r\n    end\r\n\r\n    def calcPosition(touches)\r\n        touch = touches._anyObject\r\n        location = touch._locationInView(self._view)\r\n        x = location[:x]\r\n        y = location[:y]\r\n        return [x, y]\r\n    end\r\n\r\n    define C::Void, :touchesBegan, Cocoa::Object, :withEvent, Cocoa::Object do |touches, event|\r\n        (@touchesBeganLock ||= Mutex.new).block do\r\n            x, y = calcPosition(touches)\r\n            C::call C::Void, \"AudioServicesPlaySystemSound\", $tap_se\r\n            p \":touchesBegan x:#{x}, y:#{y}\"\r\n            nyaabe_move_to(x, y)\r\n        end\r\n    end\r\n\r\n    def nyaabe_move_to(x, y)\r\n        #\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\r\n        context = C::call(C::Pointer, \"UIGraphicsGetCurrentContext\")\r\n        Cocoa::UIView._beginAnimations nil, :context, context\r\n        Cocoa::UIView._setAnimationDuration C::Double(0.2)\r\n        Cocoa::UIView._setAnimationCurve Cocoa::Const::UIViewAnimationCurveLinear\r\n        \r\n        point = CGPointMake(x, y)\r\n        @nyaabe_image_view._setCenter(point)\r\n        \r\n        Cocoa::UIView._commitAnimations\r\n    end\r\n\r\nend\r\n\r\n#BGM\r\nbgm = AudioPlayer.new(\"sht_a05\", \"mp3\")\r\nbgm.loops = -1\r\nbgm.volume = 0.25\r\nbgm.play\r\n\r\n#\u52b9\u679c\u97f3\u521d\u671f\u5316\r\nsoundPath = Cocoa::NSBundle._mainBundle._pathForResource _S(\"se_byuin\"), :ofType, _S(\"mp3\")\r\nsoundURL = Cocoa::NSURL._fileURLWithPath soundPath\r\n$tap_se = C::Int(0)\r\nC::call C::Void, \"AudioServicesCreateSystemSoundID\", soundURL, $tap_se.to_pointer\r\n\r\nscreen_rect = Cocoa::UIScreen._mainScreen._bounds\r\n$window = Cocoa::UIWindow._alloc._initWithFrame screen_rect\r\n$viewController = Cocoa::MyViewController._alloc._init\r\n\r\n$window._addSubview $viewController._view\r\n\r\n$window._makeKeyAndVisible\r\n<\/pre>\n<p>\u4eca\u65e5\u306f\u798f\u5ca1\u3067\u958b\u50ac\u3055\u308c\u308bmruby\u306e\u30bb\u30df\u30ca\u30fc\u306b\u53c2\u52a0\u3059\u308b\u306e\u3067\u3053\u308c\u304b\u3089\u798f\u5ca1\u306b\u79fb\u52d5\u3067\u3059\u3002<br \/>\nmruby\u306e\u3053\u3068\u304c\u308f\u304b\u3063\u305f\u3089MobiRuby\u306e\u3053\u3068\u304c\u3082\u3063\u3068\u308f\u304b\u308b\u306f\u305a\u3002\u305f\u306e\u3057\u307f\uff01<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2018&amp;t=MobiRuby%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E4%BD%9C%E3%82%8A%E3%81%BE%E3%81%97%E3%81%9F%28%E5%8B%95%E7%94%BB%E4%BB%98%29&amp;s=100&amp;p[url]=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2018&amp;p[images][0]=&amp;p[title]=MobiRuby%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E4%BD%9C%E3%82%8A%E3%81%BE%E3%81%97%E3%81%9F%28%E5%8B%95%E7%94%BB%E4%BB%98%29\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2018&amp;text=MobiRuby%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E4%BD%9C%E3%82%8A%E3%81%BE%E3%81%97%E3%81%9F%28%E5%8B%95%E7%94%BB%E4%BB%98%29\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&amp;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2018&amp;title=MobiRuby%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E4%BD%9C%E3%82%8A%E3%81%BE%E3%81%97%E3%81%9F%28%E5%8B%95%E7%94%BB%E4%BB%98%29\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&amp;v=3&amp;t=MobiRuby%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E4%BD%9C%E3%82%8A%E3%81%BE%E3%81%97%E3%81%9F%28%E5%8B%95%E7%94%BB%E4%BB%98%29&amp;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2018\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=MobiRuby%E3%81%AE%E3%82%B5%E3%83%B3%E3%83%97%E3%83%AB%E4%BD%9C%E3%82%8A%E3%81%BE%E3%81%97%E3%81%9F%28%E5%8B%95%E7%94%BB%E4%BB%98%29&amp;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2018\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>\u65b0\u7740\u60c5\u5831\u3001\u300e9\/22(\u571f) Ruby\u30d3\u30b8\u30cd\u30b9\u30fb\u30b3\u30e2\u30f3\u30ba\u304c\u300c\u3010RBC Tech Saturday\u3011MobiRuby\u3067iOS\u30a2\u30d7\u30ea\u3092\u3064\u304f\u308d\u3046 \uff5e\u30b9\u30de\u30db\u30a2\u30d7\u30ea\u958b\u767a\u306bmruby\u304c\u3084\u3063\u3066\u304d\u305f\uff5e\u300d\u3092\u958b\u50ac\u3057\u307e\u3059\u300f\u3067\u304a\u77e5\u3089\u305b\u3057\u3066\u304a\u308a\u307e\u3059 [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[81,51,40],"class_list":["post-2018","post","type-post","status-publish","format-standard","hentry","category-ruby","tag-mobiruby","tag-xcode","tag-40"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=2018"}],"version-history":[{"count":14,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2018\/revisions"}],"predecessor-version":[{"id":8240,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2018\/revisions\/8240"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=2018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=2018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=2018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}