-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from bugsnag/release-2.0.0
Release 2.0.0
- Loading branch information
Showing
55 changed files
with
626 additions
and
2,500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,12 @@ | |
|
||
#include "HelloWorldScene.h" | ||
#include "SimpleAudioEngine.h" | ||
#include <BugsnagCocos2dx/Bugsnag.hpp> | ||
|
||
USING_NS_CC; | ||
|
||
using namespace bugsnag; | ||
|
||
Scene* HelloWorld::createScene() | ||
{ | ||
return HelloWorld::create(); | ||
|
@@ -75,60 +78,92 @@ bool HelloWorld::init() | |
closeItem->setPosition(Vec2(x,y)); | ||
} | ||
|
||
// create menu, it's an autorelease object | ||
auto menu = Menu::create(closeItem, NULL); | ||
menu->setPosition(Vec2::ZERO); | ||
this->addChild(menu, 1); | ||
|
||
///////////////////////////// | ||
// 3. add your codes below... | ||
|
||
// add a label shows "Hello World" | ||
// create and initialize a label | ||
// Bugsnag test code | ||
|
||
auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24); | ||
if (label == nullptr) | ||
{ | ||
problemLoading("'fonts/Marker Felt.ttf'"); | ||
} | ||
else | ||
{ | ||
// position the label on the center of the screen | ||
label->setPosition(Vec2(origin.x + visibleSize.width/2, | ||
origin.y + visibleSize.height - label->getContentSize().height)); | ||
menu = Menu::create(closeItem, NULL); | ||
menu->setPosition(Vec2::ZERO); | ||
this->addChild(menu, 1); | ||
|
||
// add the label as a child to this layer | ||
this->addChild(label, 1); | ||
} | ||
topMid = Vec2(visibleSize.width/2 + origin.x, visibleSize.height + origin.y - 20); | ||
|
||
// add "HelloWorld" splash screen" | ||
auto sprite = Sprite::create("HelloWorld.png"); | ||
if (sprite == nullptr) | ||
{ | ||
problemLoading("'HelloWorld.png'"); | ||
} | ||
else | ||
{ | ||
// position the sprite on the center of the screen | ||
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); | ||
addMenuItem("Close", CC_CALLBACK_1(HelloWorld::menuCloseCallback, this)); | ||
addMenuItem("Unhandled", CC_CALLBACK_1(HelloWorld::unhandledCallback, this)); | ||
addMenuItem("Handled", CC_CALLBACK_1(HelloWorld::handledCallback, this)); | ||
addMenuItem("Metadata (Single)", CC_CALLBACK_1(HelloWorld::addMetadataSingleCallback, this)); | ||
addMenuItem("Metadata (Section)", CC_CALLBACK_1(HelloWorld::addMetadataSectionCallback, this)); | ||
addMenuItem("Leave Breadcrumb", CC_CALLBACK_1(HelloWorld::leaveBreadcrumbCallback, this)); | ||
addMenuItem("Set User", CC_CALLBACK_1(HelloWorld::setUserCallback, this)); | ||
addMenuItem("Start Session", CC_CALLBACK_1(HelloWorld::startSessionCallback, this)); | ||
addMenuItem("Pause Session", CC_CALLBACK_1(HelloWorld::pauseSessionCallback, this)); | ||
addMenuItem("Resume Session", CC_CALLBACK_1(HelloWorld::resumeSessionCallback, this)); | ||
|
||
// add the sprite as a child to this layer | ||
this->addChild(sprite, 0); | ||
} | ||
return true; | ||
} | ||
|
||
|
||
void HelloWorld::menuCloseCallback(Ref* pSender) | ||
{ | ||
abort(); // Crash the app | ||
printf("HelloWorld::menuCloseCallback\n"); | ||
|
||
//Close the cocos2d-x game scene and quit the application | ||
Director::getInstance()->end(); | ||
|
||
/*To navigate back to native iOS screen(if present) without quitting the application ,do not use Director::getInstance()->end() as given above,instead trigger a custom event created in RootViewController.mm as below*/ | ||
|
||
//EventCustom customEndEvent("game_scene_close_event"); | ||
//_eventDispatcher->dispatchEvent(&customEndEvent); | ||
} | ||
|
||
void HelloWorld::addMenuItem(const string text, const ccMenuCallback& callback) { | ||
auto mi = MenuItemLabel::create(Label::createWithTTF(text, "fonts/arial.ttf", fontSize), callback); | ||
mi->setAnchorPoint(Vec2(0.5, 1)); | ||
mi->setPosition(Vec2(topMid.x, topMid.y - menuItemHeight * menuIndex)); | ||
menu->addChild(mi); | ||
menuIndex++; | ||
} | ||
|
||
void HelloWorld::unhandledCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::unhandledCallback\n"); | ||
*badPointer = 1; | ||
} | ||
|
||
void HelloWorld::handledCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::handledCallback\n"); | ||
Bugsnag::notify("A handled error", "Something broke!"); | ||
} | ||
|
||
void HelloWorld::addMetadataSingleCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::addMetadataSingleCallback\n"); | ||
Bugsnag::addMetadata("single", "a section", "a value"); | ||
} | ||
|
||
void HelloWorld::addMetadataSectionCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::addMetadataSectionCallback\n"); | ||
Bugsnag::addMetadata("multi", {{"a", "1"}, {"b", "2"}}); | ||
} | ||
|
||
void HelloWorld::leaveBreadcrumbCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::leaveBreadcrumbCallback\n"); | ||
Bugsnag::leaveBreadcrumb("Leaving breadcrumb", State, {{"foo", "bar"}}); | ||
} | ||
|
||
void HelloWorld::setUserCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::setUserCallback\n"); | ||
Bugsnag::setUser("myuser", "[email protected]", "My User"); | ||
} | ||
|
||
void HelloWorld::startSessionCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::startSessionCallback\n"); | ||
Bugsnag::startSession(); | ||
} | ||
|
||
void HelloWorld::pauseSessionCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::pauseSessionCallback\n"); | ||
Bugsnag::pauseSession(); | ||
} | ||
|
||
void HelloWorld::resumeSessionCallback(cocos2d::Ref* pSender) { | ||
printf("HelloWorld::resumeSessionCallback\n"); | ||
printf("Bugsnag::resumeSession: %d\n", Bugsnag::resumeSession()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Bugsnag Cocos2d-x Example Project | ||
================================= | ||
|
||
This is a standard cocos2d-x project built under cocos2d-x 3.17.2 using the command line `cocos new -l cpp example-cpp-app`, and then following the [bugsnag installation instructions](https://docs.bugsnag.com/platforms/cocos2dx/). | ||
|
||
**Note**: The `bugsnag` directory is actually a symlink, and so you must first run `./scripts/export-package.sh` from the root of bugsnag-cocos2dx to generate the files needed to compile the example project (so that you're always building the example app using the current commit of bugsnag-cocos2dx). These files are what you'd normally download as a zip archive from the [releases page](https://github.com/bugsnag/bugsnag-cocos2dx/releases/latest). | ||
|
||
Projects in `proj.android` and `proj.ios_mac` can be opened, built, and run in their respective IDEs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../build/bugsnag |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.