Coder Social home page Coder Social logo

yannickl / cccontrolextension Goto Github PK

View Code? Open in Web Editor NEW
208.0 208.0 68.0 9.7 MB

Collection of classes to make the design of controls easier for Cocos2d-for-iPhone

Home Page: http://yannickloriot.com/2013/02/the-control-extension-for-cocos2d/

License: Other

Shell 0.01% Objective-C 86.94% C++ 0.49% C 12.35% GLSL 0.19% CMake 0.02%

cccontrolextension's People

Contributors

donaldalanmorrison avatar sdabet avatar yannickl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cccontrolextension's Issues

spriteWithSpriteFrameName not working

I am trying to use the sweet CCScale9Sprites constructor spriteWithSpriteFrameName

    CCScale9Sprite *bgInput = [CCScale9Sprite spriteWithSpriteFrameName:@"input-text-9S-hd.png" capInsets:CGRectMake(9, 9, 3, 3)];

But this is the result: http://cl.ly/image/3U0V0t2G0n0G

What am I doing wrong?

Looks like I am getting the whole sprite there..

Texture from Spritesheet not showing correctly

When using the CCControlButton extension, passing a sprite from a sprite sheet to it as a CCScale9Sprite results in a grey texture with black lines on it being shown (which isn't the correct texture!). I have noticed that when setting the preferred size to the contentSize of the background sprite it showed the texture correctly.

An image has been attached, and the code used to create the image is:

CCControlButton * menu_1Player = [CCControlButton buttonWithBackgroundSprite:[CCScale9Sprite spriteWithSpriteFrameName:@"player1.png"]];

for upload

Thanks.

CCScale9Sprite - Trim Support?

Hi Yannick, I've been tracking down a bug when setting up CCScale9Sprite via code. I was wondering if sprite sheet trimming was supported?

Changing defaultTouchPriority for CCControlColourPicker does not propagate to children controls

If you create an instance of CCControlColourPicker and then wish to change the touch priority for it, the effect is lost because the ivars "colourPicker" and "huePicker" do not get their defaultTouchPriority changed.

A simple fix for this would to just override the setter in CCControlColourPicker to look like this:

-(void) setDefaultTouchPriority:(NSInteger)defaultTouchPriority
{
    [super setDefaultTouchPriority:defaultTouchPriority];
    [_huePicker setDefaultTouchPriority:defaultTouchPriority];
    [_colourPicker setDefaultTouchPriority:defaultTouchPriority];
}

Warnings when compiling with Cocos2d

CCControlExtension/CCControl/CCControlPicker.m:667:60: 'labelWithString:dimensions:hAlignment:fontName:fontSize:' is deprecated
warning: no rule to process file '$(PROJECT_DIR)/CCControlExtension/CCControl/Shaders/CCControlSwitchMask.fsh' of type sourcecode.glsl for architecture armv7
warning: no rule to process file '$(PROJECT_DIR)/CCControlExtension/CCControl/Shaders/CCControlSwitchMask.fsh' of type sourcecode.glsl for architecture armv7s

CControl.m 'touchDispatcher' issue in Cocos 1.1

Using Kobold2d versions 1.0.4 and 1.1 (cocos 1.1) I get the following error:

Lines 161 and 170 of CCControl.m
Property 'touchDispatcher' not found on object of type 'CCDirector *'

- (void)onEnter
{
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
    CCTouchDispatcher * dispatcher = [CCDirector sharedDirector].touchDispatcher;
    [dispatcher addTargetedDelegate:self priority:defaultTouchPriority_ swallowsTouches:YES];
#endif
    [super onEnter];
}

- (void)onExit
{
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
    CCTouchDispatcher * dispatcher = [CCDirector sharedDirector].touchDispatcher;
    [dispatcher removeDelegate:self];
#endif

    [super onExit];
}

Deprecated methods

I get some warnings regarding deprecated methods. I'm using cocos2d 2.0. Is this a problem?

These are the conflictive lines:

[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:defaultTouchPriority_ swallowsTouches:YES];

[[CCTouchDispatcher sharedDispatcher] removeDelegate:self];

self.isRelativeAnchorPoint = YES;

Thanks

CCSlider problems

Hi,

Just been trying out the slider as a volume control for my game (Cocos2D iPhone 2.1). It, mostly, works REALLY well...

        slider = [CCControlSlider sliderWithBackgroundSprite:[CCSprite spriteWithSpriteFrameName:@"Slider-Bar.png"]
                                                               progressSprite:[CCSprite spriteWithSpriteFrameName:@"Slider-Bar-Progress.png"]
                                                                  thumbSprite:[CCSprite spriteWithSpriteFrameName:@"Slider-Pin.png"]];

        [slider setMinimumValue:0.0f];
        [slider setMaximumValue:1.0f];

        NSNumber *defaultVolume = [SDCloudUserDefaults objectForKey:@"OptionsVolume"];
        [self updateVolume:((defaultVolume != nil) ? [defaultVolume floatValue] : 1.0f) setSliderValue:YES];


        [slider setBlock:^(CCControlSlider *sender, CCControlEvent event) {
            [self updateVolume:sender.value setSliderValue:NO];
        } forControlEvents:CCControlEventValueChanged];

        [slider setAnchorPoint:ccp(0.5f, 1.0f)];
        [slider setPosition:ccp(winSize.width * 0.5f, winSize.height * 0.66f)];
        [self addChild:slider];


        CCLabelBMFont *volumeLabel = [CCLabelBMFont labelWithString:@"Volume"
                                                            fntFile:@"fntFipps-medium.fnt"
                                                              width:winSize.width
                                                          alignment:kCCTextAlignmentCenter];
        [volumeLabel setAnchorPoint:ccp(0.5f, 0.0f)];
        [volumeLabel setPosition:ccpAdd(slider.position, ccp(0.0f, 8.0f))];
        [self addChild:volumeLabel];

On my iPhone5, this works perfectly. On all simulators, this works perfectly.

On my iPad3 and my friends' iPhone 5S' the framerate while dragging is terrible. It only seems to update when you stop dragging your finger, or you do it slowly.

A separate issue is that it works when the options menu scene loads the first time, however after playing the game and quitting back to the menu, the option scene loads but I cannot drag the button on the slider. The init code above runs and it looks like the block gets added, but it seems no touch events are getting sent to it. The Back menu button on the same page works though, so the layer/scene is getting touches.

Any thoughts?

CCControlButton does not catch touches when in hud layer

This might be a usage mistake from my side, but I can't get CCControlButton to catch any touches while inside a hud layer. I implement HUD layers this way: http://www.raywenderlich.com/4666/how-to-create-a-hud-layer-with-cocos2d
In the main game layer, touches are enabled (self.touchEnabled = YES;)

Inside hudlayer.m itself I just add a new CCControlButton as child.
Something like this:

CCLabelTTF* titleRight = [CCLabelTTF labelWithString:@"→" fontName:@"Helvetica" fontSize:FONTSIZE];
titleRight.color = ccRED;
CCControlButton* buttonRight = [CCControlButton buttonWithLabel:titleRight backgroundSprite:[CCScale9Sprite spriteWithFile:@"switch-mask.png"]];
buttonRight.position = ccp(ORIGIN.x + SIZE.width, ORIGIN.y);
buttonRight.userObject = [NSValue valueWithCGPoint:ccp(1, 0)];
[buttonRight addTarget:self action:@selector(actionPan:) forControlEvents:CCControlEventTouchUpInside];
[self addChild:buttonRight];

Using buttons created with CCMenu works.

Feature request: action blocks

Instead of SEL (selectors), it would be nice to be able to use action blocks.

- (void)addTarget:(id)target action:(SEL)action forControlEvents: (CCControlEvent)controlEvents,

- (void)actionblock:(id)target ^(id sender {
        NSLog(@"Finished");
    } forControlEvents: (CCControlEvent)controlEvents, 

CCControlSwitch + cocos2d-x + mask

Hi there!

I've got a problem with CCControlSwitch from cocos2d-x extension library: mask sprite doesn't mask anything. Though it works perfect in the samples, but when I use the same code and assets in my project — it fails to draw properly.

Any suggestions? Maybe something in environment should be checked?

potentiometerButton-ipad

Filename mistake in potentiometer test detected.

"potentiometerButton -ipad.png" should be "potentiometerButton-ipad.png"

color control problem

Hi
I like your color control, but the color hex code does not correspond to the color I selected.
Also it's impossibile to select all the colors (ie: I can't get full red selected).
You will be fix this ?
Tnx
Roberto

Problem with CCControlSwitch

Hi, I tried integrating the switch to my own program.
However I have a problem with the switch's sprite. The mask, on/off sprites and on/off label are not shown when i compile and run the codes. Cannot seem to figure out what is the error. Anyone can help me? Thanks a lot in advance.

LLVM GCC 4.2 Comiler

Your project doesn't work with the LLVM GCC 4.2 Compiler, needs to be updated.

progressSprite + SpriteFrame

progressSprite textureRect fails when is loaded from a SpriteFrame, and his texture is rotated in the Texture Atlas.

if you use something like

CCControlSlider *slider = [CCControlSlider
sliderWithBackgroundSprite:[[CCSprite spriteWithSpriteFrameName:@"strack.png"]
progressSprite:[CCSprite spriteWithSpriteFrameName:@"sprogress.png"]
thumbSprite:[CCSprite spriteWithSpriteFrameName:@"sthumb.png"]];

and in the texture Atlas sprogress.png should be rotated to see the error.

CCControlPotentiometer doesn't honor anchorPoint

I'm using CCControlButton, CCControlSlider, CCControlSwitch and CCControlPotentiometer instances extensively in my debug console for my game.
It looks like the anchorPoint for CCControlPotentiometer is completely ignored and it's stuck at (0.5, 0.5).
I use the same code to build all the different controls and I'm setting a custom anchorPoint to all the CCControls and everything works except for CCControlPotentiometer.

Fantastic library anyway! Keep up the excellent work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.