Skip to content

Instantly share code, notes, and snippets.

View pkclsoft's full-sized avatar

Peter Easdown pkclsoft

View GitHub Profile
@pkclsoft
pkclsoft / SKUIViewWrapper.swift
Last active January 25, 2021 23:14
SKUIViewWrapper.swift
//
/// SKUIViewWrapper.swift
///
/// Created by Peter Easdown on 23/11/20.
///
/// This is an attempt to port the class CCUIViewWrapper from Cocos2D to Swift and SpriteKit for use
/// in my apps as I move them from the excellent Cocos2D (OpenGL based) to SpriteKit (Metal based).
///
/// Note that owing to the way the class manages the auto-adding and removal of the UIView, the wrapper
/// object should only be used once. If it is removed from the node tree, then you will need another instance
@pkclsoft
pkclsoft / CocosUtil.h
Last active January 2, 2016 10:59
Circle and Rotated Rectangle Collision Detection in Objective-C This code was ported from some code at: http://www.migapro.com/circle-and-rotated-rectangle-collision-detection/ I've changed the code to assume that it is the centre of the rectangle, not the top-left corner of the rectangle that is passed in. This makes it simpler to use from Coco…
@interface Cocosutil : NSObject
typedef struct {
float overlapSize;
BOOL intersects;
} ccIntersection;
+ (ccIntersection) intersectionOfCircleWithRadius:(float)radius
atPoint:(CGPoint)circlePt
andRectangle:(CGRect)rect
@interface NSManagedObject (Serialization)
- (NSDictionary*) toDictionary;
- (void) populateFromDictionary:(NSDictionary*)dict;
+ (NSManagedObject*) createManagedObjectFromDictionary:(NSDictionary*)dict
inContext:(NSManagedObjectContext*)context;
@end