设为首页 加入收藏

TOP

微信小程序wxss制作扭蛋机(一)
2019-09-24 18:11:15 】 浏览:111
Tags:程序 wxss 制作

小程序制作扭蛋机

2019-09-24 13:26:53

公司要制作活动小程序,其中有一个扭蛋机的效果实现抽奖的功能。在网上找了好久竟没有找到(不知道是不是我找代码的方式有问题)。最后还是自己做一个吧- _ - ,效果如下:

 

 1.wxml 

当然我这里没有用wx:for遍历

  <!-- 扭蛋机 -->
  <view class="egg">
    <image class="egg_ji" src="{{imgUrl}}small_program/game/game_luck_draw_nd.png" mode="widthFix"></image>
    <image class="play {{start?'go':''}}" bindtap="eggPlay" src="{{imgUrl}}small_program/game/game_luck_draw_eggplay.png" mode="widthFix"></image>
    <image class="ball ball_1 {{start?'weiyi_1':''}}" src="{{imgUrl}}small_program/game/game_luck_draw_egg1.png" mode="widthFix"></image>
    <image class="ball ball_2 {{start?'weiyi_2':''}}" src="{{imgUrl}}small_program/game/game_luck_draw_egg2.png" mode="widthFix"></image>
    <image class="ball ball_3 {{start?'weiyi_3':''}}" src="{{imgUrl}}small_program/game/game_luck_draw_egg3.png" mode="widthFix"></image>
    <image class="ball ball_4 {{start?'weiyi_4':''}}" src="{{imgUrl}}small_program/game/game_luck_draw_egg4.png" mode="widthFix"></image>
    <image class="ball ball_5 {{start?'weiyi_5':''}}" src="{{imgUrl}}small_program/game/game_luck_draw_egg5.png" mode="widthFix"></image>
    <image class="ball ball_6 {{start?'weiyi_6':''}}" src="{{imgUrl}}small_program/game/game_luck_draw_egg6.png" mode="widthFix"></image>
    <image class="ball ball_7 {{start?'weiyi_7':''}}" src="{{imgUrl}}small_program/game/game_luck_draw_egg7.png" mode="widthFix"></image>
   <image hidden="{{qiu}}" animation="{{ani}}" class="ball ball_end" src="{{imgUrl}}small_program/game/game_luck_draw_egg7.png" mode="widthFix" ></image>
  </view>

2.wxss

这一步比较麻烦,需要调试扭蛋的位置和动画路径

  1 /* 扭蛋机 */
  2 .egg{
  3   width: 100%;
  4   position: absolute;
  5   z-index: 3;
  6   top: 260rpx;
  7 }
  8 .egg .egg_ji{
  9   width: 70%;
 10   margin-left: 15%;
 11   z-index: 3;
 12 }
 13 .egg .play{
 14   width: 80rpx;
 15   position: absolute;
 16   z-index: 4;
 17   top: 405rpx;
 18   left: 275rpx;
 19 }
 20 .egg .ball{
 21   width: 75rpx;
 22   position: absolute;
 23   z-index: 2;
 24 }
 25 .egg .ball_1{
 26   top: 290rpx;
 27   left: 300rpx;
 28 }
 29 .egg .ball_2{
 30   top: 295rpx;
 31   left: 360rpx;
 32 }
 33 .egg .ball_3{
 34   top: 260rpx;
 35   left: 240rpx;
 36 }
 37 .egg .ball_4{
 38   top: 260rpx;
 39   left: 420rpx;
 40 }
 41 .egg .ball_5{
 42   top: 230rpx;
 43   left: 280rpx;
 44 }
 45 .egg .ball_6{
 46   top: 230rpx;
 47   left: 340rpx;
 48 }
 49 .egg .ball_7{
 50   top: 220rpx;
 51   left: 390rpx;
 52 }
 53 .egg .ball_end{
 54   top: 410rpx;
 55   left: 390rpx;
 56 }
 57 
 58 .weiyi_1 {
 59  animation: around1 1.5s linear infinite;
 60 }
 61 .weiyi_2 {
 62  animation: around2 1.5s linear infinite;
 63 }
 64 .weiyi_3 {
 65  animation: around3 1.5s linear infinite;
 66 } 
 67 .weiyi_4 {
 68  animation: around4 1.5s linear infinite;
 69 }
 70 .weiyi_5 {
 71  animati
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇JS高级程序设计笔记 下一篇jQuery——复选框操作

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目