Skip to content

Instantly share code, notes, and snippets.

@junaidk
Last active January 4, 2016 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save junaidk/8596457 to your computer and use it in GitHub Desktop.
Save junaidk/8596457 to your computer and use it in GitHub Desktop.
Cocos-touch prototype And Bootstrap Scene Files
void Scene1::ccTouchesBegan(CCSet* pTouches, CCEvent* event){
CCSetIterator i;
CCTouch* touch;
CCPoint tap;
GameSprite* tempGmSprite;
CCSprite* tempBand;
for( i = pTouches->begin(); i != pTouches->end(); i++) {
touch = (CCTouch*) (*i);
if(touch) {
tap = touch->getLocation();
//for (int p = 0; p < _tools->count()-1; p++) {}
}
}
}
void Scene1::ccTouchesMoved(CCSet* pTouches, CCEvent* event){
CCSetIterator i;
CCTouch* touch;
CCPoint tap;
GameSprite * tool ;//= tool1;
GameSprite* tempGmSprite;
for( i = pTouches->begin(); i != pTouches->end(); i++) {
touch = (CCTouch*) (*i);
if(touch) {
tap = touch->getLocation();
//for (int p = 0; p < _tools->count(); p++) {
// tempGmSprite = (GameSprite *) _tools->objectAtIndex(p);
//
// if (tempGmSprite->getTouch() != NULL && tempGmSprite->getTouch() == touch) {
//
// CCPoint nextPosition = tap;
// nextPosition.x = nextPosition.x - 35;
// nextPosition.y = nextPosition.y + 35;
// tempGmSprite->setNextPosition(nextPosition);
// //_currentTool = tempGmSprite;
//
// }
//}
}
}
}
void Scene1::ccTouchesEnded(CCSet* pTouches, CCEvent* event){
CCSetIterator i;
CCTouch* touch;
CCPoint tap;
GameSprite * tool ;//= tool1;
GameSprite* tempGmSprite;
for( i = pTouches->begin(); i != pTouches->end(); i++) {
touch = (CCTouch*) (*i);
if(touch) {
tap = touch->getLocation();
/*for (int p = 0; p < _tools->count(); p++) {
tempGmSprite = (GameSprite *) _tools->objectAtIndex(p);
CCPoint nextPosition = tap;
tempGmSprite->setTouch(NULL);
tempGmSprite->setPosition( );
}
}*/
}
}
}
#include "Scene1.h"
USING_NS_CC;
CCScene* Scene1::scene()
{
// 'scene' is an autorelease object
CCScene *scene = CCScene::create();
// 'layer' is an autorelease object
Scene1 *layer = Scene1::create();
// add layer as a child to scene
scene->addChild(layer);
// return the scene
return scene;
}
// on "init" you need to initialize your instance
bool Scene1::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(Scene1::menuCloseCallback));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
// add a label shows "Hello World"
// create and initialize a label
CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
// position the label on the center of the screen
pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
origin.y + visibleSize.height - pLabel->getContentSize().height));
// add the label as a child to this layer
this->addChild(pLabel, 1);
// add "Scene1" splash screen"
CCSprite* pSprite = CCSprite::create("Scene1.png");
// position the sprite on the center of the screen
pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
return true;
}
void Scene1::menuCloseCallback(CCObject* pSender)
{
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
/*
* SceneManager.h
*
* Created on: 13 Jun 2013
* Author: Junaid
*/
#ifndef SCENEMANAGER_H_
#define SCENEMANAGER_H_
#define CLASS_NAME "com/happy/petvet/petvet"
#include <string>
using namespace std;
class SceneManager {
public:
static void startBannerAd();
static void startBannerAdHeyZap();
static void startHeyZapInterestial();
static void startCBInterestial();
static void startSmartWallAd();
static void startAdmobFullScreen();
static void openStore();
static void openAppinStore();
static void saveSnapShot();
static void callJNIStaticMethod(string methodName, string methodSignature);
};
#endif /* SCENEMANAGER_H_ */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment