Skip to content

Instantly share code, notes, and snippets.

View tonistiigi's full-sized avatar

Tõnis Tiigi tonistiigi

  • Docker
  • San Francisco
View GitHub Profile
@tonistiigi
tonistiigi / gist:1153666
Created August 18, 2011 08:40
Dispatching mouseover/mouseout for LimeJS objects
/**
Test for correctly dispatching mouseover/mouseout for LimeJS objects
Usage: scene.listenOverOut(shape,function(e){ console.log('over'); }, function(e){ console.log('out'); });
Advice welcome about how to have the same result with more LimeJS/Closure style API.
*/
lime.Scene.prototype.listenOverOut = (function(){
@tonistiigi
tonistiigi / gist:1213745
Created September 13, 2011 12:56
MouseJoint sample added to LimeJS Box2d demo
goog.provide('test.box2d');
goog.require('box2d.BodyDef');
goog.require('box2d.BoxDef');
goog.require('box2d.CircleDef');
goog.require('box2d.CircleShape');
goog.require('box2d.PolyDef');
goog.require('box2d.Vec2');
goog.require('box2d.JointDef');
@tonistiigi
tonistiigi / gist:1758226
Created February 7, 2012 08:21
LimeJS Box2D removebody example
goog.provide('test.box2d_3');
goog.require('box2d.BodyDef');
goog.require('box2d.BoxDef');
goog.require('box2d.CircleDef');
goog.require('box2d.CircleShape');
goog.require('box2d.PolyDef');
goog.require('box2d.Vec2');
goog.require('box2d.JointDef');
goog.require('box2d.MouseJointDef');
@tonistiigi
tonistiigi / gist:2326267
Created April 7, 2012 07:37
Drag movement detection + debug
//set main namespace
goog.provide('Controller');
//get requirements
goog.require('lime.Director');
goog.require('lime.Scene');
goog.require('lime.Layer');
goog.require('lime.Circle');
goog.require('lime.Label');
@tonistiigi
tonistiigi / gist:2326275
Created April 7, 2012 07:38
Joystick control for LimeJS
goog.provide('remote.Joystick');
goog.require('lime.Sprite');
goog.require('lime.animation.FadeTo');
goog.require('lime.Circle');
goog.require('goog.events.Event');
/**
Usage:
var joystick = new remote.Joystick().setSize(200, 200).setFill('#c00').setPosition(100, 100);
@tonistiigi
tonistiigi / gist:2397232
Created April 16, 2012 09:23
LimeJS Audio updates sample.
// Still support old way:
var tromboon = new lime.audio.Audio('assets/tromboon_sample.mp3');
tromboon.play();
tromboon.stop();
// Support for audio sprites:
// Actual Zynga Player is created on first touch of the director.
var audio = new lime.audio.AudioMap({
@tonistiigi
tonistiigi / gist:2823223
Created May 29, 2012 08:10
LimeJS Sprite clone method
lime.Node.prototype.clone = function() {
var copy = new this.constructor()
.setScale(this.getScale())
.setPosition(this.getPosition())
.setSize(this.getSize())
.setAnchorPoint(this.getAnchorPoint())
.setRotation(this.getRotation())
.setAutoResize(this.getAutoResize())
.setOpacity(this.getOpacity());
for (var i = 0; i < this.children_.length; i++) {
@tonistiigi
tonistiigi / gist:2987293
Created June 25, 2012 08:12
Color comparison for LimeJS shapes
/**
* Color comparison for LimeJS shapes
* Usage:
* if (sprite.getFill().equals('#c00')) {}
* if (sprite.getFill().equals('rgb(100, 0, 0)')) {}
* if (sprite.getFill().equals(othersprite.getFill())) {}
*/
lime.fill.Color.prototype.equals = function (other) {
other = lime.fill.parse(other);
return this.r == other.r && this.g == other.g && this.b == other.b && this.a == other.a;
@tonistiigi
tonistiigi / gist:3476859
Created August 26, 2012 10:16
Moving Lime shapes with keyboard
//set main namespace
goog.provide('keycontrol');
/**
* Sample for using keyboard to naturally move around lime objects.
*/
//get requirements
goog.require('lime.Director');
goog.require('lime.Scene');
@tonistiigi
tonistiigi / gist:3931858
Created October 22, 2012 14:51
Stylus compilation information exporter
var EventEmitter = require('events').EventEmitter;
/**
* Only works with https://github.com/tonistiigi/stylus/tree/sourcemaps
* Usage:
* var StylusInfo = require('./stylusinfo').StylusInfo;
* var logger = new StylusInfo();
* var options = ...
* options._info = logger;
* stylus(str, options).render(function(err, css) {