Introduction
Do you want to feel the explosion when you blow up an Asteroid in our Space shooter? Then get the app, get the band, add MetaWear and make it real!
Hardware Build Instructions
Step 1: Unbox MetaWear.
Open your MetaWear kit and prepare to build!
Step 2: Solder the Battery to the Board
The battery included in the MetaWear kit will have wire leads. Solder the wire leads to the positive and negative battery pins on the MetaWear board.
Step 3: Solder the coin vibration motor to the Board.
There is a special output pin for driving a motor. Solder the motor between that pin and the adjacent power pin.
Step 4: Tuck the electronics inside the wristband.
The wristband from PocketBands has a good deal of space for the battery, motor, and MetaWear board. We tucked everything inside and were ready for game development!
iOS Build Instructions
We started from an iOS game from RayWenderlich which is a Space Shooter. You can find the code (as well as detailed instructions) here: http://www.raywenderlich.com/3611/cocos2d-tutorial-for-ios-how-to-make-a-space-shooter-iphone-game .
We dragged and dropped the MetaWear API files available on Github (link below)
We wanted to add a vibration each time an Asteroid was successfully destroyed so we added a couple lines of code to HelloWorldLayer.m
if (CGRectIntersectsRect(shipLaser.boundingBox, asteroid.boundingBox)) {
[[SimpleAudioEngine sharedEngine] playEffect:@"explosion_large.caf"];
[[MetaWearAPI sharedManager] pulseMotor];
}
The pulseMotor method call forces the motor to vibrate for 200 milliseconds.
Let's shoot some Asteroids!
MetaForce in Action!
Turn up the volume and hear the vibration when an asteroid is destroyed!
Build Photos
iOS Game with Mods for Vibration
https://github.com/mbientlab
Comments