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
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Cocos2d-x x iBeacon
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
Automating Front-end Workflow
addyosmani
1369
210k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6.2k
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
260
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
450
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
430
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.7k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
230
Paper Plane (Part 1)
katiecoart
PRO
1
11k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
400
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
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