html5是脚本语言,我在Animate CC中使用哪种脚本语言用于HTML5 Canvas?(What scripting language do I use for HTML5 Canvas in...

我在Animate CC中使用哪种脚本语言用于HTML5 Canvas?(What scripting language do I use for HTML5 Canvas in Animate CC?)

在Animate CC中,在Create New中,我选择了HTML 5 Canvas。 但是,当我需要将一些脚本放到项目中时,我不知道使用哪种语言。 我尝试了ActionScript和Javascript,但它们都没有为我工作,因为软件是新的,我找不到很多在线帮助。

例如,使用JavaScript(我将所有脚本放在一个图层上):

第1帧,我把:var count = 0; 警报(计数);

第2帧,我把:count = count + 1; 警报(计数);

第20帧,我把:this.gotoAndPlay(1); //转到第2帧并再次播放

第1帧的第一个“警报(计数)”工作,但第2帧的“警报(计数)”没有启动。

感谢您的帮助。

In Animate CC, in Create New, I selected HTML 5 Canvas. However, when I need to put some scripts to the project I don't know which language to use. I tried both ActionScript and Javascript but neither of them worked for me and since the software is new, I couldn't find a lot of online help.

For example, using JavaScript (I put all the scripts on one layer):

Frame 1, I put: var count = 0; alert(count);

Frame 2, I put: count = count + 1; alert(count);

Frame 20, I put: this.gotoAndPlay(1); // go to frame 2 and play again

The first "alert (count)" on frame 1 worked, but "alert(count)" on frame 2 didn't kick in.

Thank you for your help.

原文:https://stackoverflow.com/questions/36141238

更新时间:2019-11-09 14:30

最满意答案

我找到了答案。 Animate CC支持JavaScript和ActionScript。 但是,基于ActionScript的项目支持ActionScript,基于HTML5的项目支持JavaScript。

我脚本中缺少的部分是“this”。 我需要使用“this.count”而不是“count”。 默认情况下,变量范围仅在其帧代码中有效,因此为了使变量可以从其他帧访问,我需要使用“this.variableName”。

第1帧:this.count = 0;

第2帧:this.count ++; 警报(this.count);

第20帧:this.gotoAndPlay(1);

===============================

I found the answer. Both JavaScript and ActionScript are supported in Animate CC. However, ActionScript is supported in ActionScript-based projects and JavaScript is supported in HTML5-based projects.

This missing part in my script is "this". I need to use "this.count" instead just "count". By default variable scope is valid only in their frame code so in order to make the variable accessible from other frames I need to use "this.variableName".

Frame 1: this.count = 0;

Frame 2: this.count++; alert(this.count);

Frame 20: this.gotoAndPlay(1);

相关问答

好的,所以我猜在Flash或EaselJS中没有内置的功能,所以我想出了这个并且它可以正常工作。 但它只检查hitBox,矩形MovieClip边界,而不是形状中的实际可见像素。 令人沮丧的是,甚至宽度和高度都不支持Flash5 for HTML5画布中的movieclip实例的属性,因此您只需在属性面板中查看这些属性即可。 无论如何,这是我想出的: var objA = this.bullet ; // The selected MovieClip

var objA_width = 20; //

...

我找到了答案。 Animate CC支持JavaScript和ActionScript。 但是,基于ActionScript的项目支持ActionScript,基于HTML5的项目支持JavaScript。 我脚本中缺少的部分是“this”。 我需要使用“this.count”而不是“count”。 默认情况下,变量范围仅在其帧代码中有效,因此为了使变量可以从其他帧访问,我需要使用“this.variableName”。 第1帧:this.count = 0; 第2帧:this.count ++;

...

要停止所有播放声音,您可以在createjs.Sound上使用静态stop方法。 createjs.Sound.stop();

请注意,这将停止正在播放的每个声音。 您可以通过再次调用play()来恢复任何声音实例,但无法恢复所有声音实例。 更好的方法可能是将播放的声音存储在数组中,当您想要清除它们时,迭代数组以单独停止或暂停它们。 完成后,清除阵列,然后重新开始。 干杯, To stop all playing sounds, you can just use the static stop

...

实际上你需要轮子动画: createjs.Tween.get(car.wheel,{loop:true,override:true}).to({rotation:"360"}, 1000);

//or

createjs.Tween.get(car.wheel,{loop:true,override:true}).to({rotation:"-360"}, 1000);

根据新情况更新:

...

只要没有重复的名称,您应该只能一次加载所有的库。 构建导出格式是因为它是附加的 - 因此它将使用现有的lib , images和ss引用将所有lib元素组合成一个全局库。 您应该能够确认这一点,然后将所有文件组合/缩小(如果有效)。 As long as there are no duplicate names, you should be able to just load all the libs at once. The export format is built so it is add

...

面具不应该是舞台上的孩子。 将它添加到舞台使它既是面具,也是可见的孩子。 有两种简单的方法。 把可拖动的孩子放在内容后面。 这使得它不可见,但由于图像没有任何鼠标交互,它将通过鼠标按下。 唯一的副作用是由于舞台儿童对面具的别名而得到一个可见的光环。 这是一个快速示例: https : //jsfiddle.net/lannymcnie/og4pmo73/ 另一种选择是使用舞台事件,并将可拖动的孩子从舞台上移开。 舞台总是调度stagemousedown , stagemouseup和stagemo

...

目前,您只能使用Shape作为mask ,而不能使用Container或MovieClip。 如果你想做一些更复杂的事情,你可以使用像AlphaMaskFilter这样的东西 ,但它必须被缓存,然后每次掩码或内容更新时更新: something.filters = [new createjs.AlphaMaskFilter(stripeMask)];

something cache(0,0,w,h);

// On Change

something.updateCache(); // Re-cach

...

有几种方法可以解决这个问题。 一种是如果元素完全在屏幕外(如果没有交叉点),则仅将元素“移动”到另一侧。 然后移动它意味着您始终只与一个像素相交。 另一个是通过跟踪它的最后位置或知道它的轨迹来检查“它来自哪里”(如果你是动画,你可能知道这一点)。 如果它来自左边并且向右移动而你是在右侧,则它离开屏幕而你必须移动它。 但是如果它从左边出来并向右移动并且你在屏幕的左侧 ,你知道它的进入和它的确定。 There are a few ways to go about this. One is to onl

...

add context2D.beginPath(); 到draw2的开头(绘制它也不会有害) .fill填充整个路径,包括旧弧 add context2D.beginPath(); to the beginning of draw2 (it also wouldn't hurt to have it in draw) the .fill is filling the whole path which includes the old arcs

笛卡尔坐标系不定义轴的方向。 采用的计算机图形标准是左上角的原点,X轴从左到右穿过顶部,y轴从上到下穿过屏幕。 这通常是因为在过去几天内,索引到显示存储器中的CRT扫描线顺序与在最低地址处读取的第一个字节相匹配。 虽然这不适用于现代计算机,因为所有渲染调用都是首先转换的。 您可以根据需要设置原点和轴的方向。 如果您希望y轴从左下角向上,x轴从左下角向右移动,则将变换设置为ctx.setTransform(1,0,0,-1,0,499) 前2个数字是X轴像素的方向和比例,第二个是y轴像素的方向和比例

...

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值