animation.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @Description:animation.js
  3. * @Author:LCore
  4. */
  5. function showNumberWithAnimation(randx, randy, randNum) {
  6. var numberCell = $("#number-cell-" + randx + randy);
  7. numberCell.css({
  8. "background-color": getBackgroundColorByNum(randNum),
  9. "color": getPreColorByNum(randNum)
  10. });
  11. numberCell.text(getShowTextByNum(randNum));
  12. numberCell.animate({
  13. width: cellSideLength,
  14. height: cellSideLength,
  15. top: getPostionTop(randx, randy),
  16. left: getPostionLeft(randx, randy)
  17. }, 100);
  18. }
  19. function showMoveAnimation(fromX, fromY, toX, toY) {
  20. var numberCell = $("#number-cell-" + fromX + fromY);
  21. numberCell.animate({
  22. top: getPostionTop(toX, toY),
  23. left: getPostionLeft(toX, toY)
  24. }, 200);
  25. }
  26. function updateScore(score) {
  27. $('#score').text(score);
  28. }
  29. /**
  30. *@Description:积分增加动画
  31. *@Author:LCore
  32. *@pagram:坐标
  33. *@pagram:数值
  34. */
  35. function anp(element,num){
  36. var $i=$("<b>").text("+"+num);
  37. var x=element.offset().left,y=element.offset().top;
  38. $i.css({top:y,left:x+40,position:"absolute",color:"#E94F06"});
  39. $("body").append($i);
  40. $i.animate({top:y-20,opacity:0,"font-size":"14pt"},1500,function(){
  41. $i.remove();
  42. });
  43. //element.stopPropagation();
  44. }