我正在尝试快速学习动画。我爆炸了由77张图像组成的图像,但偶然发现了几个问题。
1)我试图使动画一旦出现77.png便自动停止。这是我到目前为止所拥有的。显然,它目前处于连续动画循环中。
2)动画开始需要大约1秒的延迟。但是,在动画一次后,再单击一次动画,此后即刻开始。我如何也可以立即制作第一个动画?
@IBOutlet var explosionSequence: UIImageView
var imgListArray :NSMutableArray = []
for countValue in 1...77 {
var strImageName : String = "\(countValue).png"
var image = UIImage(named:strImageName)
imgListArray .addObject(image)
}
explosionSequence.animationImages = imgListArray as [AnyObject];
explosionSequence.startAnimating()
//i want to stop animation here after all 77 .pngs have appeared
Run Code Online (Sandbox Code Playgroud)
先感谢您!!
因此,我正在尝试构建用户被提示输入"摇滚","纸张"或"剪刀"的代码,然后将其与随机计算机选择进行比较.计算机的选择被认为是0到1之间的随机值.我们的比较函数通过这两个选项并比较它们的值以返回输出,告诉哪个手势信号获胜.我收到语法错误,但似乎无法弄清楚我错过了什么.
var userChoice = prompt("Do you choose rock, paper or scissors?");
var computerChoice = Math.random();
if (computerChoice < 0.34) {
computerChoice = "rock";
} else if (computerChoice <= 0.67) {
computerChoice = "paper";
} else {
computerChoice = "scissors";
}
var compare = function(choice1, choice2) {
if (choice1 === choice2) {
return "The result is a tie!";
} else if (choice1 === "rock") {
if (choice2 === "scissors") {
return "rock wins";
} else {
return "paper wins";
}
} …Run Code Online (Sandbox Code Playgroud)