This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface SparkleSprite : CCSprite { | |
CCParticleSystemQuad * fairyDustTail_; | |
} | |
// you can either use a setter (or a property) | |
-(void) setFairyDustTail: (CCParticleSystemQuad*)fairDustTail; | |
// or you can create it internally, but in this case you need to call this method after | |
// the node has already been added to its parent so you can do: | |
// [self.parent addChild:fairDustTail_] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# magic numbers | |
scalePad = 1.5 | |
dragAfterDistance = 60 | |
recenterDelay = 1.2 | |
velocityMultiplier = 9 | |
cornerBuffer = 50 | |
# scheduled method | |
def step(deltaTime): | |
timeSinceRecenter = timeSinceRecenter + deltaTime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// quick ugly hack to get touches working on the prototype | |
if (type === "touchstart" || type === "touchmove" || type === "touchend") { | |
pos=Crafty.DOM.translate(e.touches[0].clientX, e.touches[0].clientY); | |
e.x = e.touches[0].clientX; | |
e.y = e.touches[0].clientY; | |
} | |
if (type === "touchstart") type = "mousedown"; | |
else if (type === "touchmove") type = "mousemove"; | |
else if (type === "touchend") type = "mouseup"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (type === "touchstart") type = "mousedown"; | |
else if (type === "touchmove") type = "mousemove"; | |
else if (type === "touchend") type = "mouseup"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// something similar to this | |
var lt = Date.now(); | |
var step = function() { var nt = Date.now(); var dt = nt-lt; lt = nt; Crafty.trigger("Step", dt/1000); } | |
Crafty.bind("EnterFrame", step); | |
Crafty.bind("Step", function(dt) { /* Do Stuff Here */ }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Crafty.c("Flippable", {init: function() { this.requires("2D"); }, | |
flipX: function(flipped) { this["_flipX"] = flipped; this.trigger("Changed"); }, | |
flipY: function(flipped) { this["_flipY"] = flipped; this.trigger("Changed"); } | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Crafty.c("AnchorPoint", {init: function() { this.requires("2D"); this._anchorPoint = [0.5,0.5]; this._defineGetterSetter_setter(); this._defineGetterSetter_defineProperty(); }, | |
_anchorPoint: [0.5,0.5], | |
_defineGetterSetter_setter: function() { | |
//create getters and setters using __defineSetter__ and __defineGetter__ | |
this.__defineSetter__('x', function (v) { this._attr('_x', v - this._anchorPoint[0] * this._w); }); | |
this.__defineSetter__('y', function (v) { this._attr('_y', v - this._anchorPoint[1] * this._h); }); | |
this.__defineSetter__('w', function (v) { this._attr('_w', v); this._origin.x=this._anchorPoint[0]*this._w; this.x = this.x; }); | |
this.__defineSetter__('h', function (v) { this._attr('_h', v); this._origin.y=this._anchorPoint[1]*this._h; this.y = this.y;}); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *ccRemoveHDSuffixFromFile( NSString *path ) | |
{ | |
#if CC_IS_RETINA_DISPLAY_SUPPORTED | |
if( CC_CONTENT_SCALE_FACTOR() >= 2 ) { | |
NSString *name = [path lastPathComponent]; | |
// check if path already has the suffix. | |
if( [name rangeOfString:CC_RETINA_IPAD_DISPLAY_FILENAME_SUFFIX].location != NSNotFound ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGFloat scaleFactor = (__ccPointScaleFactor == 1) ? __ccContentScaleFactor : (__ccContentScaleFactor / __ccPointScaleFactor); |
NewerOlder