Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Cocos2d-x x iBeacon
Search
Tomoo Kaku
August 20, 2014
160
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Cocos2d-x x iBeacon
Bluetoothを使ったゲームを作ろう
Tomoo Kaku
August 20, 2014
Featured
See All Featured
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
Marketing to machines
jonoalderson
1
5.9k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
360
Product Roadmaps are Hard
iamctodd
55
13k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Done Done
chrislema
187
17k
Odyssey Design
rkendrick25
PRO
2
870
GraphQLとの向き合い方2022年版
quramy
50
15k
Building the Perfect Custom Keyboard
takai
2
910
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Transcript
Cocos2d-x x iBeacon ? BluetoothΛͬͨήʔϜΛ࡞Ζ͏ ΞΫηϧϚʔΫגࣜձࣾ Tomoo Kaku
ࣗݾհ • Tomoo Kaku • ΞΫηϧϚʔΫגࣜձࣾ γχΞΤΩεύʔτ ήʔϜϑϨʔϜϫʔΫͷઃܭɾ։ൃ ݱࡏɺCocos2d-xͷήʔϜͷج൫पΓΛ୲ͯ͠ ͍·͢ɻ
• iOS /AndroidΞϓϦΛར༻ͨ͠αʔϏεͷاըɺ ઃܭɺ։ൃ • Objective-CɺC/C++ɺJavaɺRubyɺPHPͰ։ൃ
ΞδΣϯμ 1. iBeaconͱʁ 2. iBeaconΛͬͨήʔϜΛ࡞Ζ͏ 3. Cocos2d-x x Bluetooth
iBeaconͱʁ • iBeaconAppleऀͷඪ • Bluetooth Low EnergyΛར༻ͨ͠ϑϨʔϜϫʔΫ • AndroidͰ4.3͔ΒOSͰରԠ ରԠػछ·ͩগͳ͍
• ϏʔίϯͷۙΛݕग़͢Δٕज़ ͍ํنఆ͞Ε͍ͯͳ͍
iBeaconͰͰ͖Δ͜ͱ iOSͰCore Location FrameworkʹՃ͞Εͨ ·ͨɺMultipeer Connectivity FrameworkͰར༻ ͞Ε͍ͯΔ • BeaconͷྖҬ؍ଌʢRegionʣ
• Beaconͷڑ؍ଌʢRangingʣ • iOS7.1͔ΒΞϓϦ͕ىಈ͍ͯ͠ͳͯ͘ػೳ ͢ΔɻϩʔΧϧ௨ػೳʹରԠ
iBeaconΛͬͨήʔϜΛ࡞Ζ͏ ͲΜͳήʔϜ͕ग़དྷΔ͔ʁ • iBeacon(BeaconΛઃஔ) ๅ୳͠ ελϯϓϥϦʔ • P2P ͢Εҧ͍௨৴ɺۙ͘ͷಉ࢜ͷΞΠςϜަɺ ότϧɺνϟοτͳͲ͕࣮ݱՄೳ
ඞཁ݅ • Bluetooth Low EnergyʹରԠͨ͠ػछ iPhone 4SҎ߱ɺiPadୈࡾੈҎ߱ɺNaxus 5 / Nexus
7ʢ৽ܕʣ • iOS7Ҏ߱ɺAndroid 4.3Ҏ߱
ήʔϜͰͷར༻݅ • ๅ୳͠ɺελϯϓϥϦʔ iOS / Androidɹɹ̋ • P2P iOSʢiOSର߅ʣɹɹ̋ AndroidʢAndroidର߅ʣɹɹ
Androidʢηϯτϥϧʣ <-> iOSʢϖϦϑΣϥ ϧʣɹ˚
iBeaconΛͬͨήʔϜΛ࡞Γ͍ͨʢ̍ʣ • ๅ୳͠ελϯϓϥϦʔ؆୯ɺAndroidʢ4.3 Ҏ߱ͷBLEରԠʣͰಈ࡞ ͔͠͠BeaconΛஔ͠ͳͯ͘ͳΒͳ͍ => େม • ͦ͜ͰɺࠓճͷήʔϜP2PͰ࡞Δɻ BLEΛ͏ͱݱঢ়ͰɺAndroidͲ͏͠
AndroidͱiOSͰํͰଓͰ͖ͳ͍ɻiOSͷΈ ରԠʹ͢ΔɻͩͱCocos2d-xͷҙຯ͕ͳ ͍ɻɻɻɻ
iBeaconΛͬͨήʔϜΛ࡞Γ͍ͨʢ̎ʣ • ͳͷͰɺࠓճɺiOS <-> AndroidఘΊͯɺiOS <-> iOSͱAndroid <-> AndroidͰP2PʹରԠͨ͠ ήʔϜʹ͢Δ
• AndroidClassic BluetoothͰɻɻɻ ͦͷΘΓ΄ͱΜͲͷͰ͑Δ • কདྷɺAndroidͷBLEͰϖϦϑΣϥϧϞʔυ͕ ͑Δ༷ʹͳͬͨΒϋοϐʔɻ
Cocos2d-xͰBluetoothͷར༻ʢ̍ʣ ࠓճར༻Ձͷߴ͍P2Pʹઓ • iOS <-> iOSɹ̋ • Android <-> Androidɹ̋
• iOS <-> Androidɹ
Cocos2d-xͰBluetoothͷར༻ʢ̎ʣ • iOSCore LocationɺCore BluetoothɺMultipeer ConnectivityΛ༻ • AndroidClassic BluetoothΛ༻ Classic
BluetoothͱBLEͰͳ͍Bluetooth 2.1 3.0ͳͲɻϖΞϦϯάͳ͠Ͱར༻ API Level 10ʢAndroid 2.3.3ʣҎ߱
Cocos2d-xͰBluetoothͷར༻ʢ̏ʣ ಉ͡ΞϓϦͷϢʔβ͔ͷೝࣝํ๏ • iOS: ɹProximityUUIDΛήʔϜຖʹࢦఆ͢Δ • Android:ɹDeviceNameΛήʔϜຖʹࢦఆ͢Δ
UUIDͷੜํ๏ Mac OS Xͷ߹ $ uuidgen • λʔϛφϧͰuuuidgenίϚϯυͰੜ
Cocos2d-x Bluetooth P2PϓϥάΠϯ • Cocos2d-x Bluetooth P2PϓϥάΠϯΛ࡞͍ͬͯ ·͢ɻ • Cocos2d-x͔ΒσόΠε(iOS/Android)ͷҙࣝ
વ͠ͳ͍ɻ·ͨɺBLE͔Classic Bluetoothͷҙ ࣝඞཁͳ͍ɻ
Cocos2d-x Bluetooth P2PϓϥάΠϯͰͰ͖ Δ͜ͱ • جຊɺۙ͘ͷͲ͏͠ͰσʔλΛૹड৴͢ Δɻ ಛʹσʔλͷϑΥʔϚοτنఆ͍ͯ͠·ͤ ΜɻจࣈྻͳͷͰJSONͱ͔Ͱ௨৴Ͱ͖·͢ •
Cocos2d-x Bluetooth P2PϓϥάΠϯGithubʹ ஔ͖·͢ɻ(ޙ)
CCBluetooth CCBluetooth.h #define RESULT_NOTFOUND_PEER 0 #define RESULT_RECEIVE_MESSAGE 1 #define STATUS_ERROR
-1 #define STATUS_OK 1 class CCBluetoothDelegate { public: virtual void onResult(int resultCode, int status, const char *error, const char *peerID, const char *message) {}; }; class CCBluetooth { public: CCBluetooth(CCBluetoothDelegate* delegate); ~CCBluetooth(); void start(const char *peerID, const char *message); void stop(); private: CCBluetoothDelegate *_delegate; };
CCBluetooth Function // ։࢝ void start( const char *peerID, //
Ϣʔβ()Λࣝผ const char *message // ଓޙʹૹΔσʔλ ); // ऴྃ void stop();
CCBluetooth CCBluetoothDelegate void onResult( int resultCode, // ݁Ռ int status,
// εςʔλε const char *error, // Τϥʔ༰ const char *peerID, // ૬खͷID const char *message // ड͚औͬͨσʔλ );
αϯϓϧίʔυ SampleScene.cpp void SampleScene::onEnter() { cocos2d::CCLayer::onEnter(); bluetooth = new bluetooth_plugin::CCBluetooth(this);
bluetooth->start("<PeerID>", "<message>"); } void SampleScene::onExit() { cocos2d::CCLayer::onExit(); bluetooth->stop("<PeerID>", "<message>"); } // CCBluetoothDelegate void SampleScene::onResult( int resultCode, int status, const char *error, const char *peerID, const char *message) { CCLOG("૬ख: %s", peerID.c_str()); CCLOG("ϝοηʔδ: %s", message.c_str()); }
ҙ • ௨৴σʔλ͕҉߸Խ͞Εͳ͍ͨΊɺඞཁʹԠ͡ ͯΞϓϦͰ҉߸ԽΛߦ͍ͬͯͩ͘͞ɻ
ࢿྉίʔυGitHubஔ͖·͢ɻ GitHub: https://github.com/tomookaku Gist: https://gist.github.com/tomookaku facebook: https://www.facebook.com/tomoo.kaku