Skip to content

Instantly share code, notes, and snippets.

<!-- Desired Output -->
A couple sentences. <br /> A few more explaining something
<!-- Actual Output -->
A couple sentences. A few more explaining something
<!-- The result of some testing -->
<!-- Input -->
<<b>br />
<!-- Output -->
@talentless
talentless / gist:1317156
Created October 26, 2011 17:57
Extending CocosDenshion Using Categories
#import "CDAudioManager.h"
@interface CDAudioManager (ResetBackgroundMusic)
-(void) resetBackgroundMusic:(CDLongAudioSource*)preloadedAudioSource;
@end
@implementation CDAudioManager (ResetBackgroundMusic)
@talentless
talentless / TGScoreLabel.h
Created November 2, 2011 14:02
A Score Label for Cocos2d
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface TGScoreLabel : CCLabelTTF {
double curScore_; // the current score value of the label
BOOL updating_; // if we currently have an update running
double interval_; // how long we wait between updates
int score; // the target score
NSString * formatString; // the string that we format
-(void) rollToScore:(int)newScore {
self.score = newScore;
if (!updating_) {
updating_ = TRUE;
[self schedule:@selector(update_:) interval:interval_];
}
}
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface TGScoreLabel : CCLabelTTF {
double curScore_; // the current score value of the label
BOOL updating_; // if we currently have an update running
double interval_; // how long we wait between updates
int score; // the target score
NSString * formatString; // the string that we format
#import "TGScoreLabel.h"
-(void) setupPercentComplete {
TGScoreLabel * myScoreLabel = [TGScoreLabel scoreLabelWithFormatString:@"%d%%!" score:0 dimensions:CGSizeMake(380, 45) alignment:UITextAlignmentRight fontName:@"TacoGraveyard" fontSize:36];
myScoreLabel.position = myScoreLabelPosition;
[self addChild:myScoreLabel];
[myScore rollToScore: percentComplete];
}
-(void) update_:(ccTime)dt {
int direction = 1; // the score can roll in either direction
if (self.score < curScore_) {
direction = -1;
}
double pointChange = self.pointsPerSecond * direction * dt;
curScore_ += pointChange;
// don't let it overrun the target
if (direction == -1 && curScore_ < self.score) {
@talentless
talentless / CCSpriteFrameCache_SWF.h
Created November 29, 2011 14:39
CCSpriteFrameCache_SWF.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
@interface CCSpriteFrameCache (SWF)
-(void) addSpriteFramesWithSWF:(NSString*)filename;
@end
@talentless
talentless / CCSpriteFrameCache_SWF.mm
Created November 29, 2011 14:44
CCSpriteFrameCache_SWF.mm
//
// CCSpriteFrameCache_SWF.h
// CCSpriteFrameCache_SWF_Extension
//
// Created by Salvatore Gionfriddo on 11/28/11.
// Copyright (c) 2011 Taco Graveyard. All rights reserved.
//
#include <vg/openvg.h>
#include <vg/vgu.h>
@talentless
talentless / NSMutableArray_Shuggle.h
Created February 15, 2012 16:54
NSMutableArray_Shuffling header
#import <Foundation/Foundation.h>
@interface NSMutableArray (Shuffling)
-(void) shuffle;
@end