• 大小: 1.81M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2025-06-10
  • 语言: 其他
  • 标签: cocos2D  

资源简介

高仿超级马里奥,求下载!

资源截图

代码片段和文件信息

//
//  button.m
//  Classroom Demo
//
//  Created by Nick Pannuto on 2/10/10.
//  Copyright 2010 Sneakyness llc.. All rights reserved.
//

#import “SneakyButton.h“

@implementation SneakyButton

@synthesize status value active isHoldable isToggleable rateLimit radius;

-(void) onEnterTransitionDidFinish
{
#ifdef __CC_PLATFORM_IOS
    CCLOG(@“iOS SneakyInput“);
    CCDirector *director =  (CCDirector*)[CCDirector sharedDirector];
    [[director touchDispatcher] removeDelegate:self];
[[director touchDispatcher] addTargetedDelegate:self priority:1  swallowsTouches:YES];
#elif defined (__CC_PLATFORM_MAC)
    CCLOG(@“Mac SneakyInput“);
    [[[CCDirector sharedDirector] eventDispatcher] removeMouseDelegate:self];
    [[[CCDirector sharedDirector] eventDispatcher] addMouseDelegate:self priority:1];
#endif
    
    //CMLog(@“...%s...“ __PRETTY_FUNCTION__);
[super onEnterTransitionDidFinish];
}

- (void)onExit
{
#ifdef __CC_PLATFORM_IOS
    CCDirector *director =  (CCDirector*)[CCDirector sharedDirector];
[[director touchDispatcher] removeDelegate:self];
#elif defined (__CC_PLATFORM_MAC)
    [[[CCDirector sharedDirector] eventDispatcher] removeMouseDelegate:self];
#endif
[super onExit];
}

-(id)initWithRect:(CGRect)rect{
self = [super init];
if(self){

bounds = CGRectMake(0 0 rect.size.width rect.size.height);
center = CGPointMake(rect.size.width/2 rect.size.height/2);
status = 1; //defaults to enabled
active = NO;
value = 0;
isHoldable = 0;
isToggleable = 0;
radius = 32.0f;
rateLimit = 1.0f/120.0f;

position_ = rect.origin;
}
return self;
}

-(void)limiter:(float)delta{
value = 0;
[self unschedule: @selector(limiter:)];
active = NO;
}

- (void) setRadius:(float)r
{
radius = r;
radiusSq = r*r;
}

#pragma mark Touch Delegate
#ifdef __CC_PLATFORM_IOS
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
if (active) return NO;

CGPoint location = [[CCDirector sharedDirector] convertToGL:[touch locationInView:[touch view]]];
location = [self convertToNodeSpace:location];
    //Do a fast rect check before doing a circle hit check:
if(location.x < -radius || location.x > radius || location.y < -radius || location.y > radius){
return NO;
}else{
float dSq = location.x*location.x + location.y*location.y;
if(radiusSq > dSq){
active = YES;
if (!isHoldable && !isToggleable){
value = 1;
[self schedule: @selector(limiter:) interval:rateLimit];
}
if (isHoldable) value = 1;
if (isToggleable) value = !value;
return YES;
}
}
    return NO;
}

- (void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event
{
if (!active) return;

CGPoint location = [[CCDirector sharedDirector] convertToGL:[touch locationInView:[touch view]]];
location = [self convertToNodeSpace:location];
    //Do a fast rect check before doing a circle hit check:
if(location.x < -radius || location.x > radius || location.y < -radius || location.y > radius){
return;
}else{
float dSq = location.x

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-08-26 15:30  Model.xcdatamodeld\
     文件         258  2017-07-05 07:02  Model.xcdatamodeld\.xccurrentversion
     目录           0  2020-08-26 15:30  Model.xcdatamodeld\Model.xcdatamodel\
     文件         581  2017-07-05 07:02  Model.xcdatamodeld\Model.xcdatamodel\contents
     文件         991  2017-07-05 07:02  SneakyButton.h
     文件        5173  2017-07-05 07:02  SneakyButton.m
     文件         656  2017-07-05 07:02  SneakyButtonSkinnedbase.h
     文件        2712  2017-07-05 07:02  SneakyButtonSkinnedbase.m
     文件        1806  2017-07-05 07:02  SneakyJoystick.h
     文件        6241  2017-07-05 07:02  SneakyJoystick.m
     文件         536  2017-07-05 07:02  SneakyJoystickSkinnedbase.h
     文件        1830  2017-07-05 07:02  SneakyJoystickSkinnedbase.m
     目录           0  2020-08-26 15:30  SuperMario\
     文件        2633  2017-07-05 07:02  SuperMario\AppDelegate.h
     文件       10858  2017-07-05 07:02  SuperMario\AppDelegate.mm
     文件        4031  2017-07-05 07:02  SuperMario\DownWorldlayer.h
     文件      112859  2017-07-05 07:02  SuperMario\DownWorldlayer.mm
     文件        2279  2017-07-05 07:02  SuperMario\GLES-Render.h
     文件        7291  2017-07-05 07:02  SuperMario\GLES-Render.mm
     文件        2576  2017-07-05 07:02  SuperMario\GameConfig.h
     文件         553  2017-07-05 07:02  SuperMario\GameInfolayer.h
     文件        6795  2017-07-05 07:02  SuperMario\GameInfolayer.mm
     文件        1191  2017-07-05 07:02  SuperMario\Gameobject.h
     文件        3166  2017-07-05 07:02  SuperMario\Gameobject.mm
     文件        1508  2017-07-05 07:02  SuperMario\HudSticklayer.h
     文件       12499  2017-07-05 07:02  SuperMario\HudSticklayer.mm
     文件         396  2017-07-05 07:02  SuperMario\Introlayer.h
     文件        2607  2017-07-05 07:02  SuperMario\Introlayer.mm
     文件         379  2017-07-05 07:02  SuperMario\Level.h
     文件        4660  2017-07-05 07:02  SuperMario\Level.mm
     文件        4359  2017-07-05 07:02  SuperMario\MainGamelayer.h
............此处省略413个文件信息

评论

共有 条评论