当前位置:网站首页>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);
});
边栏推荐
- AppClips&Tips(持续更新)
- The classification effect of converting video classification data set to picture classification data set on vgg16
- Text overflow failure
- 修复鼠标右键没有vscode快捷入口的问题
- 通过两种方式手写一个消息队列
- 统计某次操作(函数)耗时时长
- What is sentinel produced by Ali?
- 必读1:格局越大的人,越懂得说话
- EasyGBS接入的设备视频直播突然全部无法播放是为什么?数据库读写不够
- Difference between foreach, for... In and for... Of
猜你喜欢

JS two methods to determine whether there are duplicate values in the array

Why don't we have our own programming language?

572. 另一个树的子树

关于SIoU的原理和代码实现(回顾IoU、GIoU、DIoU、CIoU)

Redux learning (I) -- the process of using Redux

Warning: Each child in a list should have a unique “key“ prop.

break,continue有什么区别和用法?

Quantitative understanding (Quantitative deep revolutionary networks for effective information: a whitepaper)

CCS method of installing compiler

UEFI查找PCI设备
随机推荐
What is sentinel produced by Ali?
A multi classification model suitable for discrete value classification -- softmax regression
Human gene editing technology and ethical issues behind it [personal view, for reference only]
JS implementation of graphic merging and sorting process [source code attached]
CCS安装编译器的方法
Illustrate the principle of one-way linked list and the method of JS to realize linked list [with source code]
Sharing of personal common software and browser plug-ins
Simple integration of client go gin six list watch two (about the improvement of RS, pod and deployment)
arguments......
Lazy load
[]==! []
Scripy web crawler series tutorials (I) | construction of scripy crawler framework development environment
During unity panoramic roaming, AWSD is used to control lens movement, EQ is used to control lens lifting, and the right mouse button is used to control lens rotation.
Notice on organizing the application for the first edition of Ningbo key software in 2022
021-MongoDB数据库从入门到放弃
What are the differences and usages of break and continue?
Communication between different VLANs
Make a small game with R language and only basic package
617. merge binary tree
PHP processing tree and infinite processing