Code Language: objective-c

Simulate NavController push/pop Animation

Language: Objective-C

//http://groups.google.com/group/cocoa-unbound/msg/78d646715a407466

@implementation UIView(MCAnimations) 
- (void)simulateNavControllerAnimateOn 
{ 
    self.alpha = 0.0f; 
    [UIView beginAnimations:@"Nav Bar Simulate On" context:nil]; 
    [UIView setAnimationDuration:0.5f]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
    self.alpha = 1.0f; 
    [UIView commitAnimations]; 
} 

- (void)simulateNavControllerAnimateOff 
{ 
    [UIView beginAnimations:@"Nav Bar Simulate Off" context:nil]; 
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut]; 
    self.transform = CGAffineTransformTranslate(self.transform, +[UIScreen mainScreen].applicationFrame.size.width, 0.f); 
    [UIView commitAnimations]; 
    [self performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.6]; 
} 

@end
Reveal More
Added 11 months ago by Atclub_256_normal scottymac

Re: cocos2d iphone functions for vectors

Refactoring of: cocos2d iphone functions for vectors

Language: Objective-C

#define PI 3.14159265358979

static inline CGPoint flipY(const CGPoint v) {
	return ccp(v.x, v.y * -1);
}

static inline CGPoint flipX(const CGPoint v) {
	return ccp(v.x * -1, v.y);
}

static inline float decByFactor(const float value, const float limit, const float factor) {

	float rv = value * factor;
	if (rv < limit) 
		rv = limit;
	return rv;
	
}

static inline float incByFactor(const float value, const float limit, const float factor) {

	float rv = value * factor;
	if (rv > limit) 
		rv = limit;
	return rv;
	
}
static inline float plotSine(const float degrees, const float min, const float max) {
	float radians = degrees * PI / 180;
	float offset = (max - min) / 2;
	return sin(radians) * offset + (min + offset);
	
}

static inline CGPoint plotCircle(const float degrees, const float radius) {								   
	float radians = degrees * PI / 180;
	return CGPointMake(sin(radians) * radius, cos(radians) * radius);
}
Reveal More
Added almost 2 years ago by Gers_10-10-09_043_normal arsydotorg

cocos2d iphone functions for vectors

Language: Objective-C

#define PI 3.14159265358979

static inline CGPoint flipY(const CGPoint v) {
	return ccp(v.x, v.y * -1);
}

static inline CGPoint flipX(const CGPoint v) {
	return ccp(v.x * -1, v.y);
}

static inline float decByFactor(const float value, const float limit, const float factor) {

	if (factor > 0) {
		return value;
	} else {
		float rv = value * factor;
		if (rv < limit) 
			rv = limit;
		return rv;
	}
	
}

static inline float incByFactor(const float value, const float limit, const float factor) {
	
	if (factor < 0) {
		return value;
	} else {
		float rv = value * factor;
		if (rv < limit) 
			rv = limit;
		return rv;
	}
	
}

static inline float plotSine(const float degrees, const float min, const float max) {
	float radians = degrees * PI / 180;
	float offset = (max - min) / 2;
	return sin(radians) * offset + (min + offset);
	
}

static inline CGPoint plotCircle(const float degrees, const float radius) {								   
	float radians = degrees * PI / 180;
	return CGPointMake(sin(radians) * radius, cos(radians) * radius);
}
Reveal More
Added almost 2 years ago by Gers_10-10-09_043_normal arsydotorg