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

Method addGeneralFrames

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

Source from the content-addressed store, hash-verified

227 }
228
229 addGeneralFrames () {
230 let action, animation, name, scale
231 const framesMap = {}
232 for (animation of Array.from(this.requiredRawAnimations())) {
233 name = animation.animation
234 const mc = this.vectorParser.buildMovieClip(name)
235 if (!mc) { continue }
236 this.builder.addMovieClip(mc, null, animation.scale * this.options.resolutionFactor)
237 framesMap[animation.scale + '_' + name] = this.builder._animations[name].frames
238 }
239
240 for (name in this.actions) {
241 action = this.actions[name]
242 if (action.animation) {
243 let left
244
245 if (name === 'portrait') { continue }
246 scale = (left = action.scale != null ? action.scale : this.get('scale')) != null ? left : 1
247 let frames = framesMap[scale + '_' + action.animation]
248 if (!frames) { continue }
249 if (action.frames != null) { frames = this.mapFrames(action.frames, frames[0]) }
250 let next = true
251 if (action.goesTo) { next = action.goesTo }
252 if (action.loops === false) { next = false }
253 this.builder.addAnimation(name, frames, next)
254 }
255 }
256
257 return (() => {
258 const result = []
259 for (name in this.actions) {
260 action = this.actions[name]
261 if (action.container && !action.animation) {
262 if (name === 'portrait') { continue }
263 scale = this.options.resolutionFactor * (action.scale || this.get('scale') || 1)
264 const s = this.vectorParser.buildContainerFromStore(action.container)
265 if (!s) { continue }
266 const frame = this.builder.addFrame(s, s.bounds, scale)
267 result.push(this.builder.addAnimation(name, [frame], false))
268 }
269 }
270 return result
271 })()
272 }
273
274 requiredRawAnimations () {
275 const required = []

Callers 1

buildSpriteSheetMethod · 0.95

Calls 3

requiredRawAnimationsMethod · 0.95
mapFramesMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected