Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

59 foggy map #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Classes/CCLayerPanZoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ bool CCLayerPanZoom::init()
return true;
}

void CCLayerPanZoom::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent){
void CCLayerPanZoom::ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent)
{
CCTouch *pTouch;
CCSetIterator setIter;
for (setIter = pTouches->begin(); setIter != pTouches->end(); ++setIter)
Expand Down Expand Up @@ -624,7 +625,8 @@ float CCLayerPanZoom::horSpeedWithPosition(CCPoint pos)
return speed;
}

float CCLayerPanZoom::vertSpeedWithPosition(CCPoint pos){
float CCLayerPanZoom::vertSpeedWithPosition(CCPoint pos)
{
CCLayerPanZoomFrameEdge edge = this->frameEdgeWithPoint(pos);
float speed = 0.0f;
if (edge == kCCLayerPanZoomFrameEdgeBottom)
Expand Down
272 changes: 136 additions & 136 deletions Classes/CCLayerPanZoom.h
Original file line number Diff line number Diff line change
@@ -1,160 +1,160 @@
/*
* CCLayerPanZoom
*
* Copyright (c) 2011 Alexey Lang
* Copyright (c) 2011 Pavel Guganov
*
* http://www.cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/
* CCLayerPanZoom
*
* Copyright (c) 2011 Alexey Lang
* Copyright (c) 2011 Pavel Guganov
*
* http://www.cocos2d-x.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*/

#include "cocos2d.h"
USING_NS_CC;

#define kCCLayerPanZoomMultitouchGesturesDetectionDelay 0.5

#ifndef INFINITY
#ifdef _MSC_VER
union MSVC_EVIL_FLOAT_HACK
{
unsigned __int8 Bytes[4];
float Value;
};
static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
#define INFINITY (INFINITY_HACK.Value)
#endif

#ifdef __GNUC__
#define INFINITY (__builtin_inf())
#endif

#ifndef INFINITY
#define INFINITY (1e1000)
#endif
#ifndef INFINITY
#ifdef _MSC_VER
union MSVC_EVIL_FLOAT_HACK
{
unsigned __int8 Bytes[4];
float Value;
};
static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
#define INFINITY (INFINITY_HACK.Value)
#endif
#ifdef __GNUC__
#define INFINITY (__builtin_inf())
#endif
#ifndef INFINITY
#define INFINITY (1e1000)
#endif
#endif


typedef enum
{
/** Standard mode: swipe to scroll */
kCCLayerPanZoomModeSheet,
/** Frame mode (i.e. drag inside objects): hold finger at edge of the screen to the sroll in this direction */
kCCLayerPanZoomModeFrame
/** Standard mode: swipe to scroll */
kCCLayerPanZoomModeSheet,
/** Frame mode (i.e. drag inside objects): hold finger at edge of the screen to the sroll in this direction */
kCCLayerPanZoomModeFrame
} CCLayerPanZoomMode;


typedef enum
{
kCCLayerPanZoomFrameEdgeNone,
kCCLayerPanZoomFrameEdgeTop,
kCCLayerPanZoomFrameEdgeBottom,
kCCLayerPanZoomFrameEdgeLeft,
kCCLayerPanZoomFrameEdgeRight,
kCCLayerPanZoomFrameEdgeTopLeft,
kCCLayerPanZoomFrameEdgeBottomLeft,
kCCLayerPanZoomFrameEdgeTopRight,
kCCLayerPanZoomFrameEdgeBottomRight
kCCLayerPanZoomFrameEdgeNone,
kCCLayerPanZoomFrameEdgeTop,
kCCLayerPanZoomFrameEdgeBottom,
kCCLayerPanZoomFrameEdgeLeft,
kCCLayerPanZoomFrameEdgeRight,
kCCLayerPanZoomFrameEdgeTopLeft,
kCCLayerPanZoomFrameEdgeBottomLeft,
kCCLayerPanZoomFrameEdgeTopRight,
kCCLayerPanZoomFrameEdgeBottomRight
} CCLayerPanZoomFrameEdge;


class CCLayerPanZoom : public cocos2d::CCLayer
{
public:
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();

// there's no 'id' in cpp, so we recommend to return the exactly class pointer
static CCLayerPanZoom* layer();

// implement the "static node()" method manually
CREATE_FUNC(CCLayerPanZoom);

void setMaxScale(float maxScale);
float maxScale();
void setMinScale(float minScale);
float minScale();
void setRubberEffectRatio(float rubberEffectRatio);
float rubberEffectRatio();

//ToDo add delegate
CC_SYNTHESIZE(float, _maxTouchDistanceToClick, maxTouchDistanceToClick);
CC_SYNTHESIZE(CCArray*, _touches, touches);
CC_SYNTHESIZE(float, _touchDistance, touchDistance);
CC_SYNTHESIZE(float, _minSpeed, minSpeed);
CC_SYNTHESIZE(float, _maxSpeed, maxSpeed);
CC_SYNTHESIZE(float, _topFrameMargin, topFrameMargin);
CC_SYNTHESIZE(float, _bottomFrameMargin, bottomFrameMargin);
CC_SYNTHESIZE(float, _leftFrameMargin, leftFrameMargin);
CC_SYNTHESIZE(float, _rightFrameMargin, rightFrameMargin);

CC_SYNTHESIZE(CCScheduler*, _scheduler, scheduler);
CC_SYNTHESIZE(float, _rubberEffectRecoveryTime, rubberEffectRecoveryTime);

CCRect _panBoundsRect;
float _maxScale;
float _minScale;

CCLayerPanZoomMode _mode;

CCPoint _prevSingleTouchPositionInLayer;
//< previous position in layer if single touch was moved.

// Time when single touch has began, used to wait for possible multitouch
// gestures before reacting to single touch.
double _singleTouchTimestamp;

// Flag used to call touchMoveBeganAtPosition: only once for each single touch event.
bool _touchMoveBegan;

float _rubberEffectRatio;
bool _rubberEffectRecovering;
bool _rubberEffectZooming;

//CCStandartTouchDelegate
void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
void ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
void ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
void ccTouchesCancelled(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);

// Updates position in frame mode.
virtual void update(float dt);
void onEnter();
void onExit();

//Scale and Position related
void setPanBoundsRect(CCRect rect);
void setPosition(CCPoint position);
void setScale(float scale);

//Ruber Edges related
void recoverPositionAndScale();
void recoverEnded();

//Helpers
float topEdgeDistance();
float leftEdgeDistance();
float bottomEdgeDistance();
float rightEdgeDistance();
float minPossibleScale();
CCLayerPanZoomFrameEdge frameEdgeWithPoint( cocos2d::CCPoint point);
float horSpeedWithPosition(CCPoint pos);
float vertSpeedWithPosition(CCPoint pos);
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();
// there's no 'id' in cpp, so we recommend to return the exactly class pointer
static CCLayerPanZoom* layer();
// implement the "static node()" method manually
CREATE_FUNC(CCLayerPanZoom);
void setMaxScale(float maxScale);
float maxScale();
void setMinScale(float minScale);
float minScale();
void setRubberEffectRatio(float rubberEffectRatio);
float rubberEffectRatio();
//ToDo add delegate
CC_SYNTHESIZE(float, _maxTouchDistanceToClick, maxTouchDistanceToClick);
CC_SYNTHESIZE(CCArray*, _touches, touches);
CC_SYNTHESIZE(float, _touchDistance, touchDistance);
CC_SYNTHESIZE(float, _minSpeed, minSpeed);
CC_SYNTHESIZE(float, _maxSpeed, maxSpeed);
CC_SYNTHESIZE(float, _topFrameMargin, topFrameMargin);
CC_SYNTHESIZE(float, _bottomFrameMargin, bottomFrameMargin);
CC_SYNTHESIZE(float, _leftFrameMargin, leftFrameMargin);
CC_SYNTHESIZE(float, _rightFrameMargin, rightFrameMargin);
CC_SYNTHESIZE(CCScheduler*, _scheduler, scheduler);
CC_SYNTHESIZE(float, _rubberEffectRecoveryTime, rubberEffectRecoveryTime);
CCRect _panBoundsRect;
float _maxScale;
float _minScale;
CCLayerPanZoomMode _mode;
CCPoint _prevSingleTouchPositionInLayer;
//< previous position in layer if single touch was moved.
// Time when single touch has began, used to wait for possible multitouch
// gestures before reacting to single touch.
double _singleTouchTimestamp;
// Flag used to call touchMoveBeganAtPosition: only once for each single touch event.
bool _touchMoveBegan;
float _rubberEffectRatio;
bool _rubberEffectRecovering;
bool _rubberEffectZooming;
//CCStandartTouchDelegate
void ccTouchesBegan(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
void ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
void ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
void ccTouchesCancelled(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent);
// Updates position in frame mode.
virtual void update(float dt);
void onEnter();
void onExit();
//Scale and Position related
void setPanBoundsRect(CCRect rect);
void setPosition(CCPoint position);
void setScale(float scale);
//Ruber Edges related
void recoverPositionAndScale();
void recoverEnded();
//Helpers
float topEdgeDistance();
float leftEdgeDistance();
float bottomEdgeDistance();
float rightEdgeDistance();
float minPossibleScale();
CCLayerPanZoomFrameEdge frameEdgeWithPoint( cocos2d::CCPoint point);
float horSpeedWithPosition(CCPoint pos);
float vertSpeedWithPosition(CCPoint pos);
};
2 changes: 1 addition & 1 deletion Classes/ChooseCharacterScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void ChooseCharacterScene::CharacterTouched(CCObject *pSender)

void ChooseCharacterScene::addBackButton()
{
CCSprite *back = CCSprite::create("Images/Game/UI/button-back.png");
CCSprite* back = CCSprite::create("Images/Game/UI/button-back.png");
CCMenuItemSprite *backBtn = CCMenuItemSprite::create(back,
back,
this,
Expand Down
4 changes: 2 additions & 2 deletions Classes/ChooseMapScence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ void ChooseMapScene::mapTouched(CCObject *pSender)
void ChooseMapScene::buttonRandomTouched(cocos2d::CCObject *pSender)
{
CCLog("button random touched");
srand (time(NULL));
int r = ((int)random())%10+1;
srand(time(NULL));
int r = rand()%10+1;
CCLog("r = %i", r);
mSlidingMap->moveToPage(r-1);
}
Expand Down
14 changes: 10 additions & 4 deletions Classes/Constant.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "cocos2d.h"

USING_NS_CC;
// the gap between dot of indicator
#define GAP_BETWEEN_DOT 37.78f

#define GAP_BETWEEN_DOT 37.78f // the gap between dot of indicator

#define SCREEN_SIZE CCDirector::sharedDirector()->getWinSize()
// ChooseMapScene
Expand Down Expand Up @@ -85,8 +85,14 @@ enum eEdgeStatus

enum eCurrentPlayer
{
PLAYER_ONE = 1,
PLAYER_TWO = 2,
PLAYER_ONE,
PLAYER_TWO
};

enum eFog
{
FOGGY = 20,
UNFOGGY = 255
};

#endif
Loading