简体   繁体   English

减少累积奖金游戏中文字的眨眼速度

[英]easing speed of blink for text in a jackpot game

I am making a jackpot game with a selector very similar to this one 我想提出一个大奖游戏很相似,选择这一项

I have absolutely no idea where to start. 我完全不知道从哪里开始。 My first thought was to use an array of randomly selected numbers sent from the server side to avoid cheating and animate those with jquery or css. 我的第一个想法是使用从服务器端发送的一组随机选择的数字,以避免使用jquery或css欺骗和设置动画。

Then i thought about useing just jquery since i know it better and having the blink interval be a recursive fucnction that returns the values for easing speed i want. 然后我考虑只使用jquery,因为我更了解它,并且让眨眼间隔是一种递归函数,它返回我想要的放松速度的值。 (the values would be pretty much exactly like in the video, no more than 3-4 seconds). (该值几乎与视频中的值完全相同,不超过3-4秒)。

$('.blink').blink(); // default is 500ms blink interval.
$('.blink').blink(100); // causes a 100ms blink interval.

But now I am at a loss for where to get started since this has to be mobile friendly. 但是现在我对于从哪里开始感到迷茫,因为这必须是移动友好的。 What would you do? 你会怎么做?


UPDATE 更新

$( document ).ready(function() {

var time = 0;
var diff = 50;
var minTime = 0;
var maxTime = 7000;


function easeInOutExpo(t, b, c, d) {
    t /= d;
    return c*t*t*t + b;
};


$("#clickme").click(function() {
    for (var i = 0, len = diff; i <= len; i++) {
      (function(s) {
        setTimeout(function() {
            $('#book').html("Page " + s + " turned");
        }, time);
      })(i); //<--------------i have no clue what this does------------
      time = easeInOutExpo(i, minTime, maxTime, diff);
    }
});

});//document ready

I've gotten the basic mechanic down, but when you click on it a second time instead of 50 it goes to 0. this is not good behavior as I am going to use these numbers to iterate through a randomly generated array. 我已经掌握了基本的技巧,但是当您第二次单击它而不是50时,它变为0。这不是一个好行为,因为我将使用这些数字来遍历随机生成的数组。

Can anyone explain this behaviour? 谁能解释这种行为? I've included a JS fiddle here. 我在这里包括了一个JS小提琴。 Thank you! 谢谢!

You can use simple css animation. 您可以使用简单的CSS动画。

 @keyframes blink { 0% { background-color:red; } 10% { background-color:purple; } 20% { background-color:gray; } 30% { background-color:green; } 40% { background-color:white; } 50% { background-color:cyan; } 65% { background-color:yellow; } 100% { background-color:black } } .Blink{ animation: blink 2s 1 ease-out; background-color:black; height:100px; width:100px; } 
 <div class="Blink"> 

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

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