gpt4 book ai didi

html - 如何使用 createJS 和 Flash CC 在 Movieclip 上使用缓存

转载 作者:行者123 更新时间:2023-11-27 23:47:36 24 4
gpt4 key购买 nike

大家好,我想问一下。我用 Flash CC 和 createJS 制作了一个游戏。这是一个拖放游戏(3 个对象用于拖放,3 个对象用于放置)和很多矢量动画片段对象。但是当我在手机上运行它时,游戏看起来有性能问题。我读过一些关于 caching 对象的文章。但我真的对 cache 一无所知,也不知道如何在像 movieclip 这样的对象上使用它。您有任何解释或解决方案,或者如何使用 cache 功能的教程吗?非常感谢。

最佳答案

来自文档:

Draws the display object into a new canvas, which is then used for subsequent draws. For complex content that does not change frequently (ex. a Container with many children that do not move, or a complex vector Shape), this can provide for much faster rendering because the content does not need to be re-rendered each tick. The cached display object can be moved, rotated, faded, etc freely, however if its content changes, you must manually update the cache by calling updateCache() or cache() again. You must specify the cache area via the x, y, w, and h parameters. This defines the rectangle that will be rendered and cached using this display object's coordinates. http://createjs.com/Docs/EaselJS/classes/DisplayObject.html#method_cache

因此,您不想缓存正在播放的 MovieClip(您必须每帧都更新缓存,这很慢)。但是,您可以在 MC 中缓存刚刚被转换的元素。

例如,行走角色的动画, ARM 、腿部、头部和 body 的复杂矢量形状经过变换(缩放、旋转、平移)以创建行走动画。您不会缓存角色 MC,但可以缓存 body 部位本身。

关于html - 如何使用 createJS 和 Flash CC 在 Movieclip 上使用缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29028144/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com