当前位置:网站首页>Aircraft war from scratch (II) simple development
Aircraft war from scratch (II) simple development
2022-06-11 06:46:00 【Dare you look at the avatar for three seconds?】
Last time we set up a background picture to move from top to bottom on the stage , But because there is only one background picture , There will always be a moment when the background image will slide down , That is to say, our background maintains a short continuity , But not for a long time , So we have to solve this problem , We need to load two background pictures on the stage as soon as we open , Use the clock control to control the two pictures to move together , And judge the position of the two pictures relative to the stage in real time , When the first picture is finished, the second picture is on the top , At the end of the second chapter, the first picture is on the top
stay html Add two pictures to
<div id="stage">
<div class="bg1"></div>
<div class="bg2"></div>
</div>
js
$(function(){
// When writing code here, you can control all htmldom Node
//dom
var stage=document.getElementById("stage"); // Get stage nodes
var bg1=stage.getElementsByClassName("bg1")[0];// Get a background picture
// console.log(bg1) // Check to see if... Is captured bg1
var bg2=stage.getElementsByClassName("bg2")[0];// Get a background picture
var topval=-200;
var topval2=-968;
var k=0;
// bg1.style.cssText="top: -30px;"
var t1=setInterval(function(){
k++;
if(k==768){
topval=-968;
}else if(k==768*2){
topval2-968;
k=0;
}
// console.log("ddd")
// console.log(bg1.style.cssText)
// bg1.scrollTop=bg1.scrollTop+10;
bg1.style.cssText="top: "+topval+"px";
topval+=1;
bg2.style.cssText="top: "+topval2+"px";
topval2+=1;
//topval++ The background moves down
},10);
// t1.clearInterval(); // The clock stopped
// Chapter II pictures
// var stage=document.getElementById("stage"); // Get stage nodes
// // console.log(bg1) // Check to see if... Is captured bg1
// // bg1.style.cssText="top: -30px;"
// var t1=setInterval(function(){
// // console.log("ddd")
// // console.log(bg1.style.cssText)
// // bg1.scrollTop=bg1.scrollTop+10;
// bg2.style.cssText="top: "+topval2+"px";
// topval2+=1
// //topval++ The background moves down
// },70);
});
边栏推荐
- Oracle prompt invalid number
- 235-二叉搜索树的最近公共祖先
- 【概率论与数理统计】猴博士 笔记 p41-44 统计量相关小题、三大分布的判定、性质、总体服从正态分布的统计量小题
- Convert multiple pictures into one NPY file storage
- 347. top k high frequency elements
- 572. subtree of another tree
- Handwritten a message queue in two ways
- Metasploitabile2 target learning
- About the principle and code implementation of Siou (review IOU, giou, Diou, CIO)
- 数学方法论的含义和研究意义
猜你喜欢

Redux learning (III) -- using Redux saga, writing middleware functions, and splitting reducer files

A piece of code has been refactored six times by the boss, and my mind is broken

Redux learning (II) -- encapsulating the connect function

网狐游戏服务器房间配置向导服务定制功能页实现

538.把二叉搜索树转换成累加树

QT script document translation (I)

双周投融报:资本抢滩元宇宙游戏

jenkins-不同风格的项目构建

Implementation of customization function page of online Fox game server room configuration wizard service

关于SIoU的原理和代码实现(回顾IoU、GIoU、DIoU、CIoU)
随机推荐
[]==! []
arguments......
[]==![]
Lazy load
关于SIoU的原理和代码实现(回顾IoU、GIoU、DIoU、CIoU)
懒加载,预加载
Sentinel annotation support - @sentinelresource usage details
Autojs, read one line, delete one line, and stop scripts other than your own
Docker installation of MySQL and redis
text-overflow失效
Wan Zichang's article shows you promise
On cursor in MySQL
Differences between FindIndex and indexof
Human gene editing technology and ethical issues behind it [personal view, for reference only]
必读1:格局越大的人,越懂得说话
SQL language - query statement
Do you use typescript or anyscript
双周投融报:资本抢滩元宇宙游戏
解决ffmpeg獲取AAC音頻文件duration不准
Handwritten promise [05] - exception capture of promise method and optional parameters of then method implementation