mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-28 23:13:59 -04: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
app/lib/surface
test/app/lib/surface
|
@ -63,7 +63,7 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
|
||||||
@setThang @options.thang
|
@setThang @options.thang
|
||||||
if @thang?
|
if @thang?
|
||||||
options = @thang?.getSpriteOptions?()
|
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
|
console.error @toString(), 'has no ThangType!' unless @thangType
|
||||||
|
|
||||||
# this is a stub, use @setImageObject to swap it out for something else later
|
# 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]
|
for mc in @spriteSheet.mcPool[key]
|
||||||
if not mc.inUse
|
if not mc.inUse
|
||||||
mc.gotoAndStop(mc.currentFrame+0.01) # just to make sure it has its children back
|
mc.gotoAndStop(mc.currentFrame+0.01) # just to make sure it has its children back
|
||||||
|
@childMovieClips = mc.childMovieClips
|
||||||
return mc
|
return mc
|
||||||
|
|
||||||
raw = @thangType.get('raw')
|
raw = @thangType.get('raw')
|
||||||
|
@ -132,6 +133,7 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
|
||||||
anim.nominalBounds = new createjs.Rectangle(animData.bounds...)
|
anim.nominalBounds = new createjs.Rectangle(animData.bounds...)
|
||||||
if animData.frameBounds
|
if animData.frameBounds
|
||||||
anim.frameBounds = (new createjs.Rectangle(bounds...) for bounds in animData.frameBounds)
|
anim.frameBounds = (new createjs.Rectangle(bounds...) for bounds in animData.frameBounds)
|
||||||
|
anim.childMovieClips = @childMovieClips
|
||||||
|
|
||||||
@spriteSheet.mcPool[key].push(anim)
|
@spriteSheet.mcPool[key].push(anim)
|
||||||
return anim
|
return anim
|
||||||
|
@ -234,7 +236,7 @@ module.exports = class SegmentedSprite extends createjs.SpriteContainer
|
||||||
movieClip.gotoAndStop(newFrame) for movieClip in @childMovieClips
|
movieClip.gotoAndStop(newFrame) for movieClip in @childMovieClips
|
||||||
@children = []
|
@children = []
|
||||||
@takeChildrenFromMovieClip()
|
@takeChildrenFromMovieClip()
|
||||||
|
|
||||||
takeChildrenFromMovieClip: ->
|
takeChildrenFromMovieClip: ->
|
||||||
i = 0
|
i = 0
|
||||||
while i < @baseMovieClip.children.length
|
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']
|
for prop in ['regX', 'regY', 'rotation', 'scaleX', 'scaleY', 'skewX', 'skewY', 'x', 'y']
|
||||||
newChild[prop] = child[prop]
|
newChild[prop] = child[prop]
|
||||||
@addChild(newChild)
|
@addChild(newChild)
|
||||||
@alreadyLogged = true
|
|
||||||
i += 1
|
i += 1
|
||||||
else
|
else
|
||||||
@addChild(child)
|
@addChild(child)
|
||||||
|
|
|
@ -35,7 +35,7 @@ describe 'SegmentedSprite', ->
|
||||||
|
|
||||||
describe 'with Tree ThangType', ->
|
describe 'with Tree ThangType', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
layer = new LayerAdapter({webGL:true})
|
layer = new LayerAdapter({webGL:true, name:'Default'})
|
||||||
layer.buildAutomatically = false
|
layer.buildAutomatically = false
|
||||||
layer.buildAsync = false
|
layer.buildAsync = false
|
||||||
treeThangType.markToRevert()
|
treeThangType.markToRevert()
|
||||||
|
@ -90,7 +90,7 @@ describe 'SegmentedSprite', ->
|
||||||
|
|
||||||
describe 'with Ogre Munchkin ThangType', ->
|
describe 'with Ogre Munchkin ThangType', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
layer = new LayerAdapter({webGL:true})
|
layer = new LayerAdapter({webGL:true, name:'Default'})
|
||||||
layer.buildAutomatically = false
|
layer.buildAutomatically = false
|
||||||
layer.buildAsync = false
|
layer.buildAsync = false
|
||||||
ogreMunchkinThangType.markToRevert()
|
ogreMunchkinThangType.markToRevert()
|
||||||
|
@ -98,9 +98,9 @@ describe 'SegmentedSprite', ->
|
||||||
actions = ogreMunchkinThangType.getActions()
|
actions = ogreMunchkinThangType.getActions()
|
||||||
|
|
||||||
# couple extra actions for doing some tests
|
# 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.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}
|
actions.onestep = {animation:'enemy_small_move_side', loops: false, name:'onestep'}
|
||||||
actions.head = {container:'head'}
|
actions.head = {container:'head', name:'head'}
|
||||||
|
|
||||||
colorConfig = {team: {hue: 0, saturation: 1, lightness: 0.5}}
|
colorConfig = {team: {hue: 0, saturation: 1, lightness: 0.5}}
|
||||||
sprite = new CocoSprite(ogreMunchkinThangType, {colorConfig: colorConfig})
|
sprite = new CocoSprite(ogreMunchkinThangType, {colorConfig: colorConfig})
|
||||||
|
|
|
@ -40,7 +40,7 @@ describe 'SingularSprite', ->
|
||||||
|
|
||||||
describe 'with Tree ThangType', ->
|
describe 'with Tree ThangType', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
layer = new LayerAdapter({webGL:true})
|
layer = new LayerAdapter({webGL:true, name:'Default'})
|
||||||
layer.buildAutomatically = false
|
layer.buildAutomatically = false
|
||||||
layer.buildAsync = false
|
layer.buildAsync = false
|
||||||
treeThangType.markToRevert()
|
treeThangType.markToRevert()
|
||||||
|
@ -90,7 +90,7 @@ describe 'SingularSprite', ->
|
||||||
|
|
||||||
describe 'with Ogre Munchkin ThangType', ->
|
describe 'with Ogre Munchkin ThangType', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
layer = new LayerAdapter({webGL:true})
|
layer = new LayerAdapter({webGL:true, name:'Default'})
|
||||||
layer.buildAutomatically = false
|
layer.buildAutomatically = false
|
||||||
layer.buildAsync = false
|
layer.buildAsync = false
|
||||||
ogreMunchkinThangType.markToRevert()
|
ogreMunchkinThangType.markToRevert()
|
||||||
|
|
|
@ -49,7 +49,7 @@ describe 'SpriteBoss', ->
|
||||||
window.stage = stage = new createjs.SpriteStage(canvas[0])
|
window.stage = stage = new createjs.SpriteStage(canvas[0])
|
||||||
options = {
|
options = {
|
||||||
camera: camera
|
camera: camera
|
||||||
surfaceLayer: stage
|
webGLStage: stage
|
||||||
surfaceTextLayer: new createjs.Container()
|
surfaceTextLayer: new createjs.Container()
|
||||||
world: world
|
world: world
|
||||||
thangTypes: thangTypes
|
thangTypes: thangTypes
|
||||||
|
@ -112,7 +112,7 @@ describe 'SpriteBoss', ->
|
||||||
midRenderExpectations.push([spriteBoss.sprites['Singular Ogre'].imageObject.paused,true,'animated singular action'])
|
midRenderExpectations.push([spriteBoss.sprites['Singular Ogre'].imageObject.paused,true,'animated singular action'])
|
||||||
|
|
||||||
defaultLayer.once 'new-spritesheet', ->
|
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()
|
done()
|
||||||
|
|
||||||
beforeEach (done) -> init(done)
|
beforeEach (done) -> init(done)
|
||||||
|
@ -159,8 +159,8 @@ describe 'SpriteBoss', ->
|
||||||
expect(spriteBoss.sprites['Ogre S'].imageObject.y).toBeCloseTo(60)
|
expect(spriteBoss.sprites['Ogre S'].imageObject.y).toBeCloseTo(60)
|
||||||
|
|
||||||
it 'scales sprites according to thang scaleFactorX and scaleFactorY', ->
|
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 N'].imageObject.scaleX).toBe(spriteBoss.sprites['Ogre N'].imageObject.baseScaleX * 1.5)
|
||||||
expect(spriteBoss.sprites['Ogre W'].imageObject.scaleY).toBe(spriteBoss.sprites['Ogre N'].baseScaleY * 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', ->
|
it 'sets alpha based on thang alpha', ->
|
||||||
expect(spriteBoss.sprites['Ogre E'].imageObject.alpha).toBe(0.5)
|
expect(spriteBoss.sprites['Ogre E'].imageObject.alpha).toBe(0.5)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue