Skip to content

Instantly share code, notes, and snippets.

View mattcolman's full-sized avatar

Matt Colman mattcolman

View GitHub Profile
@mattcolman
mattcolman / new gist
Created September 14, 2012 00:32
new gist
define [
'caper/game_state'
'easel'
'caper/util'
'underscore'
], (GameState, {Bitmap, Container, Text, SpriteSheet}, {randInt, extractFrame, removeObj}, _) ->
class Main extends GameState
@mattcolman
mattcolman / activity.coffee
Created September 14, 2012 00:34
Activity template new
define [
'caper/game_state'
'easel'
'caper/util'
'underscore'
], (GameState, {Bitmap, Container, Text, SpriteSheet}, {randInt, extractFrame, removeObj}, _) ->
class Main extends GameState
@mattcolman
mattcolman / define.coffee
Created September 14, 2012 00:39
about defines
define [
'caper/game_state'
'easel'
'caper/util'
'underscore'
], (GameState, {Bitmap, Container, Text, SpriteSheet}, {randInt, extractFrame, removeObj}, _) ->
@mattcolman
mattcolman / actor.coffee
Created September 17, 2012 05:38
Actor class
define [
'caper/actor'
], (Actor) ->
class SampleActor extends Actor
added: (@parent, @pos) ->
@cnt = new Container()
@cnt.x = @pos.x
@cnt.y = @pos.y
@parent.addChild @cnt
@mattcolman
mattcolman / drag_drop.coffee
Created September 17, 2012 06:03
Drag and drop
define [
'caper/actor'
], (Actor) ->
class Ball extends Actor
added: ->
#DRAGGABLE
@dragImage = @bitmap 'draggy'
@stage.addChild @dragImage
@mattcolman
mattcolman / aspect-ratio.coffee
Created September 21, 2012 05:56
Aspect ratio
class Main extends Activity
enter: ->
super
@mainCnt = new Container()
@stage.addChild @mainCnt
@adjustForAspectRatio @mainCnt
@mattcolman
mattcolman / hit_area.coffee
Created September 21, 2012 06:03
HitArea
@cnt.addHitArea new Rectangle(0, 0, 200, 300), false
@droppable = new Droppable(@cnt)
@mattcolman
mattcolman / extract_frame.coffee
Created September 27, 2012 03:41
Extracting a frame from a Spritesheet
img = @mySpritesheet.bitmapFromFrame 'frameLabelOrIndex'
img.centreRegistrationPoint()
@stage.addChild img
@mattcolman
mattcolman / clickable.coffee
Created September 27, 2012 03:48
Clickable
# turn a DisplayObject 'coin' into a Clickable object
coin = @bitmap 'coin'
coin.centreRegistrationPoint()
coin.x = coin.y = 300
@stage.addChild coin
@clickable = @makeClickable coin, {over: @bitmap('coin_light'), down: @bitmap('coin_dark')}
@clickable.on 'click', @handleClick
# use the SimpleButton class to create...a simple button
# call @method in 2 seconds
@delayedCall(2, @method)
# delete the delayedCall
@tweenMax.killDelayedCallsTo(@method)