简体   繁体   English

如何为ActionScript-3中的按钮设置动画?

[英]How to animate a button in ActionScript-3?

I have a game and I want to add some animations to it like highlighting things that can be used. 我有一个游戏,我想向其中添加一些动画,例如突出显示可以使用的东西。 (This is more about effects) (这更多关于效果)

Example: see image below 示例:见下图


If I want to highlight the green dices, how could I do that in theory? 如果要突出显示绿色骰子,理论上该怎么做? And with what tricks? 有什么花招?
I thought of: 我想到了:

  • add glitter to buttons (easy) 为按钮添加闪光(简单)
  • shake buttons a bit (easy) 摇一下按钮(简单)
  • reflection effects (no idea ...) 反射效果(不知道...)

What else can I do? 我还可以做些什么?

Thanks for any ideas and tips! 感谢您的任何想法和提示!


i frequently work with AS3 and what i usualy do when coding is the following: 1.Divide your Problem into small packages 2.Solve the first package and go on 3.Finetune your code for better dynamics and most importantly for further use so it can be used in other Projects to 我经常使用AS3,在编码时通常会做以下工作:1.将问题分成小包2.解决第一个包并继续操作3.微调代码以获得更好的动态性,最重要的是进一步使用它,以便在其他项目中使用

Now to your problem: 1. How do you target the green dices only? 现在开始解决您的问题:1.如何仅将绿色骰子作为目标? 2. How do you target one dice only instead of all at once or none at all? 2.您如何只瞄准一个骰子而不是一次或根本不瞄准? 3. How do you dynamicaly add effects? 3.您如何动态添加效果?

So first of all what Event qould you need, are you targeting them qith the keys? 因此,首先需要的是什么事件,是否要通过键来将它们作为目标? if yes then give the current element a boolean which turns active so you can go if(greenDice.true) do this the if statement needs to be in a constant loop. 如果是,则给当前元素一个布尔值,该布尔值将变为活动状态,因此您可以执行if(greenDice.true) do this ,如果if语句需要处于恒定循环中。 if you target it with your mouse it is a lot simpler, you can just use the mouseOver event and in it use an if statement if(e.currentTarget == greenDice) myFunction() in your called function you can animate it. 如果使用鼠标将其作为目标, if(e.currentTarget == greenDice) myFunction()简单得多,您可以使用mouseOver事件,并在被调用函数中使用if语句if(e.currentTarget == greenDice) myFunction()进行动画处理。 Now you have it, you can call any event on your dice, the said effects qould probably be created with the flash filters http://www.republicofcode.com/tutorials/flash/as3filters/ change the different parameters in a loop and there you have it, check out other filters too. 现在您拥有了它,您可以在骰子上调用任何事件,可能会使用Flash过滤器http://www.republicofcode.com/tutorials/flash/as3filters/在循环中更改不同的参数来创建上述效果您拥有它,也可以查看其他过滤器。 Have fun coding and best regards 祝您编程愉快,并致以最诚挚的问候

Raphael 拉斐尔

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM