This file contains hidden or 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
//: Playground - noun: a place where people can play | |
// The Swift Programming Language | |
// iBook Page 6 (13" screen display with full screen) | |
// Basic string operations | |
import UIKit | |
// declare two variables | |
let apples = 3 | |
let oranges = 5 |
This file contains hidden or 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
// declare a variable. variable can keep on changing the values | |
var myVariable = 42 | |
// modifying variable value | |
myVariable = 50 | |
// defining constant | |
let myConstant = 100 | |
// following is an example of implicit declaration of integer variable |
This file contains hidden or 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
// | |
// LocationManager.m | |
// http://SagarRKothari.com | |
// | |
// Created by SagarRKothari on 12/5/14. | |
// | |
// | |
#import "LocationManager.h" |
This file contains hidden or 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
// | |
// LocationManager.h | |
// http://SagarRKothari.com | |
// | |
// Created by SagarRKothari on 12/5/14. | |
// | |
// | |
#import <Foundation/Foundation.h> | |
#import <CoreLocation/CoreLocation.h> |
This file contains hidden or 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
- (UIImage *)getTheScreenShotFromWindow | |
{ | |
// get the window size | |
UIWindow *window = [[[UIApplication sharedApplication] delegate] window]; | |
CGSize size = window.size; | |
// check the scale - retina or regular | |
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) | |
UIGraphicsBeginImageContextWithOptions(size, NO, [UIScreen mainScreen].scale); | |
else |
This file contains hidden or 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
// step 1. include it from extensions. | |
#include "extensions/GUI/CCScrollView/CCScrollView.h" | |
// get the screen size | |
Size visibleSize = Director::getInstance()->getVisibleSize(); | |
// get the origin | |
Vec2 origin = Director::getInstance()->getVisibleOrigin(); | |
// create a container-layer with white color-background & having 90% of screen size & 1200px vertical size |
This file contains hidden or 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
bool AppDelegate::applicationDidFinishLaunching() { | |
s_AppDelegate = this; | |
// initialize director | |
auto director = Director::getInstance(); | |
auto glview = director->getOpenGLView(); | |
if(!glview) { | |
glview = GLView::create("My Game"); | |
director->setOpenGLView(glview); | |
} | |
This file contains hidden or 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
// create the sprite | |
auto spriteLeft = Sprite::create("FortuneWheel.png"); | |
// get the texture size / image size | |
auto spriteLeftRect = spriteLeft->getTextureRect(); | |
// set the position of sprite | |
spriteLeft->setPosition(Vec2(visibleSize.width-spriteLeftRect.size.width/2-20 , spriteLeftRect.size.height/2+40)); | |
// add the sprite to scene-layer |
This file contains hidden or 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
// in .h file | |
class HelloWorld : public cocos2d::LayerColor | |
{ | |
public: | |
bool myTouchBegan(cocos2d::Touch *pTouch, cocos2d::Event *pEvent); | |
void myTouchMoved(cocos2d::Touch *pTouch, cocos2d::Event *pEvent); | |
void myTouchEnded(cocos2d::Touch *pTouch, cocos2d::Event *pEvent); | |
} | |
// in .m file |