英文:
Why aren't my A-Frame animations looping properly?
问题
我正在尝试让这些动画循环播放,但它们只运行一次然后停止。我的代码如下:
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<a-scene>
<a-box height="0.1" width="3" depth="7" position="0 3.5 0" color="#964800" rotation="45 0 0"
animation__first="property: rotation; from: 45 0 0; to: -45 0 0; dur: 300 startEvents: loaded, animationcomplete__second;"
animation__second="property: rotation; from: -45 0 0; to: 45 0 0; delay: 500; startEvents: animationcomplete__first;">
<a-cone radius-bottom="1.5" radius-top="1.5" height="1.5" position="0 .75 2" color="#964800"></a-cone>
</a-box>
</a-scene>
我尝试将"first"和"second" 更改为 "1" 和 "2",但没有变化,我还尝试更改"loaded"和"animationcomplete"的顺序,同样没有改变。
英文:
I am trying to get these animations to loop, but they only run once each then stop. My code is as follows
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<a-scene>
<a-box height=0.1 width=3 depth=7 position="0 3.5 0" color="#964800" rotation="45 0 0"
animation__first="property:rotation; from:45 0 0; to:-45 0 0; dur:300 startEvents:loaded, animationcomplete__second;"
animation__second="property:rotation; from:-45 0 0; to:45 0 0; delay:500; startEvents:animationcomplete__first;">
<a-cone radius-bottom=1.5 radius-top=1.5 height=1.5 position="0 .75 2" color="#964800"></a-cone>
</a-box>
</a-scene>
I've tried changing the first and second to 1 and 2 with no change and I tried changing the order of loaded and animationcomplete which, once again, changed nothing.
答案1
得分: 1
以下是翻译好的部分:
You're missing a semicolon in the first animation (so i guess the startEvents
aren't properly parsed at all, and the first animation starts on loaded
by default. With the semicolon it works properly:
<!-- begin snippet: js hide: false console: false babel: false -->
<!-- language: lang-html -->
<script src="https://aframe.io/releases/1.4.0/aframe.min.js"></script>
<a-scene>
<a-box height=0.1 width=3 depth=7 position="0 3.5 -5" color="#964800" rotation="45 0 0"
animation__first="property:rotation; from:45 0 0; to:-45 0 0;
dur:300; startEvents:loaded, animationcomplete__second;"
animation__second="property:rotation; from:-45 0 0; to:45 0 0;
delay:500; startEvents: animationcomplete__first;">
<a-cone radius-bottom=1.5 radius-top=1.5 height=1.5 position="0 .75 2" color="#964800"></a-cone>
</a-box>
</a-scene>
<!-- end snippet -->
英文:
You're missing a semicolon in the first animation (so i guess the startEvents
aren't properly parsed at all, and the first animation starts on loaded
by default. With the semicolon it works properly:
<!-- begin snippet: js hide: false console: false babel: false -->
<!-- language: lang-html -->
<script src="https://aframe.io/releases/1.4.0/aframe.min.js"></script>
<a-scene>
<a-box height=0.1 width=3 depth=7 position="0 3.5 -5" color="#964800" rotation="45 0 0"
animation__first="property:rotation; from:45 0 0; to:-45 0 0;
dur:300; startEvents:loaded, animationcomplete__second;"
animation__second="property:rotation; from:-45 0 0; to:45 0 0;
delay:500; startEvents: animationcomplete__first;">
<a-cone radius-bottom=1.5 radius-top=1.5 height=1.5 position="0 .75 2" color="#964800"></a-cone>
</a-box>
</a-scene>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论