search
HomeWeb Front-endH5 TutorialDavid Lanham 新 iOS 遊戲 “Hatch” 的官網視頻中,最後小寵物從畫面跑進網頁的效果是如何實現的?

官網地址:hatchpet.com/ 視頻需翻牆。

回复内容:

var scale = 1;
var baseHeight = 544 * scale;
var baseWidth = 602 * scale;
var eachFrame = 15;

var canvas = $('<canvas id="canvas"/>').css({
	'position': 'fixed',
	'zIndex': 9999,
	'bottom': '0',
	'overflow': 'hidden',
}).attr({
	'width': baseWidth,
	'height': baseHeight,
});

$('body').append(canvas);


var frameCnt = 0;
var context = canvas[0].getContext('2d');

function animate(isReset) {
	if (isReset) {
		frameCnt = 0;
	};
	// clear
	context.clearRect(0, 0, baseWidth, baseHeight);
	// draw stuff
	context.drawImage(imageObjs[parseInt(frameCnt / eachFrame)], (frameCnt % eachFrame) * baseWidth, 0, baseWidth, baseHeight, 0, 0, baseWidth, baseHeight);
	frameCnt++;
	// request new frame
	if (frameCnt < eachFrame * 2) {
		setTimeout(animate, 1000 / 8);
	} else {
		animate(true);
	}
}

var pic = [
	'http://p1.zhimg.com/8c/fb/8cfbc0eb11019584c7ee0dccd4c8bf66_r.jpg',
	'http://p1.zhimg.com/4f/3d/4f3db206b0fd094ef2fc00ece876ad30_r.jpg'
];


function preLoadImages(imgSrcList, callback) {
	var imageObjs = [];
	var len = imgSrcList.length;
	var callbackAfter = len;

	var preloadInterval = window.setInterval(function() {
		if (callbackAfter === 0) {
			window.clearInterval(preloadInterval);
			callback();
		}
	}, 100);


	for (var i = 0; i < len; i++) {
		imageObjs[i] = new Image();
		imageObjs[i].onload = function() {
			callbackAfter--;
		};
		imageObjs[i].src = imgSrcList[i];
	};



	return imageObjs;
}

var imageObjs = preLoadImages(pic, function() {
	animate(true);
});
弱答。
HTML 源文件里发现了 id 为 licksprite, licksprite2 的两个 div。可以看到其背景图片如下,确定了和可爱的小怪兽动画有关: David Lanham 新 iOS 遊戲 “Hatch” 的官網視頻中,最後小寵物從畫面跑進網頁的效果是如何實現的? David Lanham 新 iOS 遊戲 “Hatch” 的官網視頻中,最後小寵物從畫面跑進網頁的效果是如何實現的?在密密麻麻的压缩过的 js 源文件里搜了一下 licksprite ,还真发现了踪影:
var licksprite;var showingSprite=false;var playState;var playerReady=false;var shouldStart=false;var spriteTime=50.08;…
我对 js 只是非常一知半解,不过那个 spriteTime = 50.08 让人猜想,应该是检测在视频播放50.08秒后,触发网页上的 CSS sprite 动画。
在 YouTube 上搜到了这个视频(youtube.com/watch?)。确实是在50s和51s秒之间,小怪物跑出来了~

至于更具体的实现方式,我就看不出来了,应该有某种机制检测视频播放时间线吧。订制在页面里的播放器,阻止了用户手动调整播放进度,这样就不需要处理太复杂的情况。

最后说一句题外话,多谢本问题,我才看到这个可爱的小彩蛋~
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Mastering Microdata: A Step-by-Step Guide for HTML5Mastering Microdata: A Step-by-Step Guide for HTML5May 14, 2025 am 12:07 AM

MicrodatainHTML5enhancesSEOanduserexperiencebyprovidingstructureddatatosearchengines.1)Useitemscope,itemtype,anditempropattributestomarkupcontentlikeproductsorevents.2)TestmicrodatawithtoolslikeGoogle'sStructuredDataTestingTool.3)ConsiderusingJSON-LD

What's New in HTML5 Forms? Exploring the New Input TypesWhat's New in HTML5 Forms? Exploring the New Input TypesMay 13, 2025 pm 03:45 PM

HTML5introducesnewinputtypesthatenhanceuserexperience,simplifydevelopment,andimproveaccessibility.1)automaticallyvalidatesemailformat.2)optimizesformobilewithanumerickeypad.3)andsimplifydateandtimeinputs,reducingtheneedforcustomsolutions.

Understanding H5: The Meaning and SignificanceUnderstanding H5: The Meaning and SignificanceMay 11, 2025 am 12:19 AM

H5 is HTML5, the fifth version of HTML. HTML5 improves the expressiveness and interactivity of web pages, introduces new features such as semantic tags, multimedia support, offline storage and Canvas drawing, and promotes the development of Web technology.

H5: Accessibility and Web Standards ComplianceH5: Accessibility and Web Standards ComplianceMay 10, 2025 am 12:21 AM

Accessibility and compliance with network standards are essential to the website. 1) Accessibility ensures that all users have equal access to the website, 2) Network standards follow to improve accessibility and consistency of the website, 3) Accessibility requires the use of semantic HTML, keyboard navigation, color contrast and alternative text, 4) Following these principles is not only a moral and legal requirement, but also amplifying user base.

What is the H5 tag in HTML?What is the H5 tag in HTML?May 09, 2025 am 12:11 AM

The H5 tag in HTML is a fifth-level title that is used to tag smaller titles or sub-titles. 1) The H5 tag helps refine content hierarchy and improve readability and SEO. 2) Combined with CSS, you can customize the style to enhance the visual effect. 3) Use H5 tags reasonably to avoid abuse and ensure the logical content structure.

H5 Code: A Beginner's Guide to Web StructureH5 Code: A Beginner's Guide to Web StructureMay 08, 2025 am 12:15 AM

The methods of building a website in HTML5 include: 1. Use semantic tags to define the web page structure, such as, , etc.; 2. Embed multimedia content, use and tags; 3. Apply advanced functions such as form verification and local storage. Through these steps, you can create a modern web page with clear structure and rich features.

H5 Code Structure: Organizing Content for ReadabilityH5 Code Structure: Organizing Content for ReadabilityMay 07, 2025 am 12:06 AM

A reasonable H5 code structure allows the page to stand out among a lot of content. 1) Use semantic labels such as, etc. to organize content to make the structure clear. 2) Control the rendering effect of pages on different devices through CSS layout such as Flexbox or Grid. 3) Implement responsive design to ensure that the page adapts to different screen sizes.

H5 vs. Older HTML Versions: A ComparisonH5 vs. Older HTML Versions: A ComparisonMay 06, 2025 am 12:09 AM

The main differences between HTML5 (H5) and older versions of HTML include: 1) H5 introduces semantic tags, 2) supports multimedia content, and 3) provides offline storage functions. H5 enhances the functionality and expressiveness of web pages through new tags and APIs, such as and tags, improving user experience and SEO effects, but need to pay attention to compatibility issues.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Atom editor mac version download

Atom editor mac version download

The most popular open source editor