Skip to content

Instantly share code, notes, and snippets.

Andrey Syrokomskiy signmotion

View GitHub Profile
signmotion / rapidjson_gen_json.cpp
Created May 16, 2018 — forked from fclairamb/rapidjson_gen_json.cpp
Write some JSON using a rapidjson library
View rapidjson_gen_json.cpp
#ifdef SHELL
g++ -Wall -Werror -g -I../../cclib/rapidjson/include $0 && ./a.out
exit 0
// Output is:
// {"project":"rapidjson","stars":11}
// {"Name":"XYZ","Rollnumer":2,"array":["hello","world"],"Marks":{"Math":"50","Science":"70","English":"50","Social Science":"70"}}
// {"FromEmail":"","FromName":"Sender's name","Subject":"My subject","Recipients":[{"Email":""}],"Text-part":"this is my text"}
signmotion / Scale image to fullscreen.cpp
Last active Apr 9, 2018
Scale image to fullscreen user:signmotion #cocos2d-x
View Scale image to fullscreen.cpp
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
auto bg = Sprite::create("menubg.png");
bg->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2));
// To make the image fit the screen no matter what the resolution is, you need to scale the image.
// To scale the image to perfectly fit the screen:
bg->setScale(visibleSize.width / bg->getContentSize().width, visibleSize.height / bg->getContentSize().height);
You can’t perform that action at this time.