MCPcopy Create free account
hub / github.com/codecombat/codecombat / addPortrait

Method addPortrait

app/models/ThangType.js:207–227  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

205 }
206
207 addPortrait () {
208 // The portrait is built very differently than the other animations, so it gets a separate function.
209 if (!this.actions) { return }
210 const { portrait } = this.actions
211 if (!portrait) { return }
212 const scale = portrait.scale || 1
213 const pt = portrait.positions != null ? portrait.positions.registration : undefined
214 const rect = new createjs.Rectangle(((pt != null ? pt.x : undefined) / scale) || 0, ((pt != null ? pt.y : undefined) / scale) || 0, 100 / scale, 100 / scale)
215 if (portrait.animation) {
216 const mc = this.vectorParser.buildMovieClip(portrait.animation)
217 mc.nominalBounds = (mc.frameBounds = null) // override what the movie clip says on bounding
218 this.builder.addMovieClip(mc, rect, scale)
219 let { frames } = this.builder._animations[portrait.animation]
220 if (portrait.frames != null) { frames = this.mapFrames(portrait.frames, frames[0]) }
221 return this.builder.addAnimation('portrait', frames, true)
222 } else if (portrait.container) {
223 const s = this.vectorParser.buildContainerFromStore(portrait.container)
224 const frame = this.builder.addFrame(s, rect, scale)
225 return this.builder.addAnimation('portrait', [frame], false)
226 }
227 }
228
229 addGeneralFrames () {
230 let action, animation, name, scale

Callers 1

buildSpriteSheetMethod · 0.95

Calls 1

mapFramesMethod · 0.95

Tested by

no test coverage detected