Skip to content

Instantly share code, notes, and snippets.

View mattcolman's full-sized avatar

Matt Colman mattcolman

View GitHub Profile
@mattcolman
mattcolman / semiColonDiff.jsx
Last active March 26, 2017 10:50
Semi-colon diff example
const a = 'a'
const b = 'been'
const c = () => {
return a
}
@mattcolman
mattcolman / block_diff.jsx
Last active March 26, 2017 04:36
Block diff
function helloWorld() {
return <ShoppingList
name="Sunday Shop"
items={7}
status={2}
/>
}
@mattcolman
mattcolman / custom_movieclip_loader.js
Last active March 1, 2016 02:48
Custom MovieClip Loader
CustomLoader = function(item) {
this.AbstractLoader_constructor(item, false, 'loader')
}
CustomLoader.getPreloadHandlers = function() {
return {
types: [ 'some_custom_type' ]
callback: CustomLoader.preloadHandler
}
}
@mattcolman
mattcolman / good-bad-js.coffee
Created November 5, 2015 05:31
Good Bad JS Examples (coffeescript)
# ---------------------------------------------------------- #
# EXAMPLE 1
# ---------------------------------------------------------- #
#
# BAD
addPoints: ->
pts = []
for i in [0...100]
pts.push @getRandomPointFromRect new Rectangle(0, i * 20, 20, 20)
$(document).bind("keydown", function (e) {
if (e.keyCode == 8) { // backspace
e.preventDefault()
// do whatever the backspace should do
}
}
@mattcolman
mattcolman / fat_thin.coffee
Created February 13, 2014 00:09
fat or thin arrow
# Fat arrow implementation
box.on 'go', @handleGo
handleGo: (e) =>
e.target.removeListener 'go', @handleGo
@game.nextState()
# Thin arrow implementation
scope = @
box.on 'go', ->
@removeListener 'go', @
@mattcolman
mattcolman / movieclips.coffee
Last active December 13, 2015 21:08
Movieclips
@documentMC = @newMovieClip('movieclip_filename', 'MyClassName')
# If you enter the class name as the filename you can import the main timeline from the FLA,
# unless you have specifically changed the name of the Document class.
@mainCnt.addChild @documentMC
# **** MONSTER **** #
monster = @documentMC.monster
monster.onClick = =>
monster.gotoAndPlay('correct')
@mattcolman
mattcolman / add_assets.coffee
Last active December 13, 2015 21:08
Adding assets
# add a bitmap
newBitmap = @bitmap('my_bitmap')
@stage.addChild(newBitmap)
# extract frame 2 from a spriteSheet and use it as a bitmap
newSpriteSheet = @spriteSheet('my_spritesheet')
newSpriteSheet.bitmapFromFrame(2)
@stage.addChild(newSpriteSheet)
# add a BitmapAnimation
@mattcolman
mattcolman / tally.yml
Created October 19, 2012 03:25
Tally
:variables:
<<: *caper_common
<<: *tally
tally_spacing:
:content:
- 35