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 / 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 / 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)
@mattcolman
mattcolman / tally.yml
Created October 19, 2012 03:25
Tally
:variables:
<<: *caper_common
<<: *tally
tally_spacing:
:content:
- 35
actor = @addActor "sample_actor", SampleActor, parent, {x:10, y:20}
:variables:
<<: *caper_common
<<: *lives
lives_options:
:content:
- {xoffset: 20, yoffset: 0, lives: 4}
@mattcolman
mattcolman / barebones.yml
Created October 7, 2012 22:18
barebones yml
barebones:
<<: *js_activity
:variables:
<<: *caper_common
<<: *results_sfx
extra_assets:
:content:
- barebones
assets:
- image: