mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Fixed a bunch of tests, and a child animations bug from the MovieClip pooling optimization.
This commit is contained in:
parent
6d595705f2
commit
024cd9c955
5 changed files with 15 additions and 14 deletions
|
@ -63,7 +63,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
|||
@setThang @options.thang
|
||||
if @thang?
|
||||
options = @thang?.getSpriteOptions?()
|
||||
@options.colorConfig = options.colorConfig if options.colorConfig
|
||||
@options.colorConfig = options.colorConfig if options and options.colorConfig
|
||||
console.error @toString(), 'has no ThangType!' unless @thangType
|
||||
|
||||
# this is a stub, use @setImageObject to swap it out for something else later
|
||||
|
|
|
@ -98,6 +98,7 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
|
|||
for mc in @spriteSheet.mcPool[key]
|
||||
if not mc.inUse
|
||||
mc.gotoAndStop(mc.currentFrame+0.01) # just to make sure it has its children back
|
||||
@childMovieClips = mc.childMovieClips
|
||||
return mc
|
||||
|
||||
raw = @thangType.get('raw')
|
||||
|
@ -132,6 +133,7 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
|
|||
anim.nominalBounds = new createjs.Rectangle(animData.bounds...)
|
||||
if animData.frameBounds
|
||||
anim.frameBounds = (new createjs.Rectangle(bounds...) for bounds in animData.frameBounds)
|
||||
anim.childMovieClips = @childMovieClips
|
||||
|
||||
@spriteSheet.mcPool[key].push(anim)
|
||||
return anim
|
||||
|
@ -234,7 +236,7 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
|
|||
movieClip.gotoAndStop(newFrame) for movieClip in @childMovieClips
|
||||
@children = []
|
||||
@takeChildrenFromMovieClip()
|
||||
|
||||
|
||||
takeChildrenFromMovieClip: ->
|
||||
i = 0
|
||||
while i < @baseMovieClip.children.length
|
||||
|
@ -251,7 +253,6 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
|
|||
for prop in ['regX', 'regY', 'rotation', 'scaleX', 'scaleY', 'skewX', 'skewY', 'x', 'y']
|
||||
newChild[prop] = child[prop]
|
||||
@addChild(newChild)
|
||||
@alreadyLogged = true
|
||||
i += 1
|
||||
else
|
||||
@addChild(child)
|
||||
|
|
|
@ -35,7 +35,7 @@ describe 'SegmentedSprite', ->
|
|||
|
||||
describe 'with Tree ThangType', ->
|
||||
beforeEach ->
|
||||
layer = new LayerAdapter({webGL:true})
|
||||
layer = new LayerAdapter({webGL:true, name:'Default'})
|
||||
layer.buildAutomatically = false
|
||||
layer.buildAsync = false
|
||||
treeThangType.markToRevert()
|
||||
|
@ -90,7 +90,7 @@ describe 'SegmentedSprite', ->
|
|||
|
||||
describe 'with Ogre Munchkin ThangType', ->
|
||||
beforeEach ->
|
||||
layer = new LayerAdapter({webGL:true})
|
||||
layer = new LayerAdapter({webGL:true, name:'Default'})
|
||||
layer.buildAutomatically = false
|
||||
layer.buildAsync = false
|
||||
ogreMunchkinThangType.markToRevert()
|
||||
|
@ -98,9 +98,9 @@ describe 'SegmentedSprite', ->
|
|||
actions = ogreMunchkinThangType.getActions()
|
||||
|
||||
# couple extra actions for doing some tests
|
||||
actions.littledance = {animation:'enemy_small_move_side',framerate:1, frames:'0,6,2,6,2,8,0'}
|
||||
actions.onestep = {animation:'enemy_small_move_side', loops: false}
|
||||
actions.head = {container:'head'}
|
||||
actions.littledance = {animation:'enemy_small_move_side',framerate:1, frames:'0,6,2,6,2,8,0', name: 'littledance'}
|
||||
actions.onestep = {animation:'enemy_small_move_side', loops: false, name:'onestep'}
|
||||
actions.head = {container:'head', name:'head'}
|
||||
|
||||
colorConfig = {team: {hue: 0, saturation: 1, lightness: 0.5}}
|
||||
sprite = new CocoSprite(ogreMunchkinThangType, {colorConfig: colorConfig})
|
||||
|
|
|
@ -40,7 +40,7 @@ describe 'SingularSprite', ->
|
|||
|
||||
describe 'with Tree ThangType', ->
|
||||
beforeEach ->
|
||||
layer = new LayerAdapter({webGL:true})
|
||||
layer = new LayerAdapter({webGL:true, name:'Default'})
|
||||
layer.buildAutomatically = false
|
||||
layer.buildAsync = false
|
||||
treeThangType.markToRevert()
|
||||
|
@ -90,7 +90,7 @@ describe 'SingularSprite', ->
|
|||
|
||||
describe 'with Ogre Munchkin ThangType', ->
|
||||
beforeEach ->
|
||||
layer = new LayerAdapter({webGL:true})
|
||||
layer = new LayerAdapter({webGL:true, name:'Default'})
|
||||
layer.buildAutomatically = false
|
||||
layer.buildAsync = false
|
||||
ogreMunchkinThangType.markToRevert()
|
||||
|
|
|
@ -49,7 +49,7 @@ describe 'SpriteBoss', ->
|
|||
window.stage = stage = new createjs.SpriteStage(canvas[0])
|
||||
options = {
|
||||
camera: camera
|
||||
surfaceLayer: stage
|
||||
webGLStage: stage
|
||||
surfaceTextLayer: new createjs.Container()
|
||||
world: world
|
||||
thangTypes: thangTypes
|
||||
|
@ -112,7 +112,7 @@ describe 'SpriteBoss', ->
|
|||
midRenderExpectations.push([spriteBoss.sprites['Singular Ogre'].imageObject.paused,true,'animated singular action'])
|
||||
|
||||
defaultLayer.once 'new-spritesheet', ->
|
||||
showMe() # Uncomment to display this world when you run any of these tests.
|
||||
# showMe() # Uncomment to display this world when you run any of these tests.
|
||||
done()
|
||||
|
||||
beforeEach (done) -> init(done)
|
||||
|
@ -159,8 +159,8 @@ describe 'SpriteBoss', ->
|
|||
expect(spriteBoss.sprites['Ogre S'].imageObject.y).toBeCloseTo(60)
|
||||
|
||||
it 'scales sprites according to thang scaleFactorX and scaleFactorY', ->
|
||||
expect(spriteBoss.sprites['Ogre N'].imageObject.scaleX).toBe(spriteBoss.sprites['Ogre N'].baseScaleX * 1.5)
|
||||
expect(spriteBoss.sprites['Ogre W'].imageObject.scaleY).toBe(spriteBoss.sprites['Ogre N'].baseScaleY * 1.5)
|
||||
expect(spriteBoss.sprites['Ogre N'].imageObject.scaleX).toBe(spriteBoss.sprites['Ogre N'].imageObject.baseScaleX * 1.5)
|
||||
expect(spriteBoss.sprites['Ogre W'].imageObject.scaleY).toBe(spriteBoss.sprites['Ogre N'].imageObject.baseScaleY * 1.5)
|
||||
|
||||
it 'sets alpha based on thang alpha', ->
|
||||
expect(spriteBoss.sprites['Ogre E'].imageObject.alpha).toBe(0.5)
|
||||
|
|
Loading…
Reference in a new issue