Сложное движение элементов
Всем привет.
Солнце вращается по элиптической орбите вокруг некоторого центра. Земля, в свою очередь, вращается вокруг Солнца, также по элиптической орбите. Наконец, Луна вращается вокруг Земли, опять же, по элиптической орбите. И все это вращается одновременно! Изображения есть, необходимо установить солнце посередине экрана и задать вращение. Формулы должны быть рабочие, не могу понять почему не работает. Помогите пожалуйста! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//RU"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251"> <META NAME="Author" CONTENT="Eugene P. Lilitko"> <TITLE>Сложное движение элементов</TITLE> <SCRIPT language="JavaScript"> <!-- function initObject(obj,radius,angleinc,anglestart,directio n,vertical,horizontal) { obj.radius = radius; obj.angleinc = angleinc; obj.anglestart = anglestart; obj.angle = anglestart; obj.direction = direction; obj.vertical = vertical; obj.horizontal = horizontal; obj.centerX = parseInt(obj.left) - horizontal*radius*Math.cos(anglestart*Math.PI/180); obj.centerY = parseInt(obj.top) + vertical*radius*Math.sin(anglestart*Math.PI/180); obj.move = circleMove(); } function circleMove() { with (this) { angle += direction*angleinc; left = centerX + horizontal*radius*Math.cos(angle*Math.PI/180); top = centerY - vertical*radius*Math.sin(angle*Math.PI/180); } } function init() { var NN = (navigator.appName == "Netscape"); speed = 20; moon =(NN) ? document.layers["allSpan"].document.layers["earthMoonSpan"].document.layers["moonSpan"] : document.all["moonSpan"].style; earth = (NN) ? document.layers["allSpan"].document.layers["earthMoonSpan"].document.layers["earthSpan"] : document.all["earthSpan"].style; earthMoon = (NN) ? document.layers["allSpan"].document.layers["earthMoonSpan"] : document.all["earthMoonSpan"].style; sun = (NN) ? document.layers["allSpan"] : document.all["allSpan"].style; initObject(earthMoon,2,1.5,20,1,1,1); initObject(moon,16,4,0,-1,1,2); initObject(sun,75,1,180,1,1,2); moveObjects() } var sunDelay = true; function moveObjects() { earthMoon.move(); moon.move(); sunDelay = !sunDelay; if (sunDelay) sun.move(); if (parseInt(moon.top) < parseInt(earth.top)) { if (moon.zIndex != 1) moon.zIndex = 3; } else { if (moon.zIndex != 3) moon.zIndex = 1; } setTimeout("moveObjects()",speed) } //--> </SCRIPT> </HEAD> <BODY TEXT="white" LINK="AQUA" VLINK="YELLOW" BACKGROUND="./pic/stars.gif" onLoad="init()"> <SPAN ID="allSpan" STYLE="position:absolute; left:232; top:80; width:336; height:316;"> <SPAN ID="sunSpan" STYLE="position:absolute; left:300; top:90; width:71;"> <IMG SRC="./pic/sun.gif" WIDTH=71 HEIGHT=71 BORDER=0> </SPAN> <SPAN ID="earthMoonSpan" STYLE="position:absolute; left:0; top:72; width:100; height:100;"> <SPAN ID="earthSpan" STYLE="position:absolute; z-index:2; left:34; top:34; width:32; height:32;"> <IMG SRC="./pic/earth.gif" WIDTH=32 HEIGHT=32 BORDER=0> </SPAN> <SPAN ID="moonSpan" STYLE="position:absolute; left:80; top:40; width:20; height:20;"> <IMG SRC="./pic/moon.gif" WIDTH=20 HEIGHT=20 BORDER=0> </SPAN> </SPAN> </SPAN> </BODY> </HTML> |
Цитата:
|
http://old.mkgt.ru/files/material-st.../demo/css5.htm
мне препад дал задание, пытался вникнуть в код... |
Цитата:
|
Смотрю через Chrome. Теги <layer></layer>? В этом и загвоздка. Не понимаю, как их правильно применить.
|
|
Спасибо. В IE работает, а в Chrome нет. Как мне исправить?
|
daw2nalim_alex,
:cray: :cray: :cray: document.getElementById видимо вам неизвестно ...
<!DOCTYPE>
<HTML>
<HEAD>
<meta charset="utf-8">
<META NAME="Author" CONTENT="Eugene P. Lilitko">
<TITLE>Сложное движение элементов</TITLE>
<SCRIPT >
function initObject(obj,radius,angleinc,anglestart,directionLI,vertical,horizontal) {
obj.radius = radius;
obj.angleinc = angleinc;
obj.anglestart = anglestart;
obj.angle = anglestart;
obj.directionLI = directionLI;
obj.vertical = vertical;
obj.horizontal = horizontal;
obj.centerX = parseInt(obj.left) - horizontal*radius*Math.cos(anglestart*Math.PI/180);
obj.centerY = parseInt(obj.top) + vertical*radius*Math.sin(anglestart*Math.PI/180);
obj.move = circleMove;
}
function circleMove() {
with (this) {
angle += directionLI*angleinc;
left = centerX + horizontal*radius*Math.cos(angle*Math.PI/180)+'px';
top = centerY - vertical*radius*Math.sin(angle*Math.PI/180)+'px';
}
}
function init() {
speed = 20;
moon = document.getElementById("moonSpan").style;
earth =document.getElementById("earthSpan").style;
earthMoon = document.getElementById("earthMoonSpan").style;
sun = document.getElementById("allSpan").style;
initObject(earthMoon,125,1.5,20,1,1,1);
initObject(moon,16,4,0,-1,1,2);
initObject(sun,75,1,180,1,1,2);
moveObjects()
}
var sunDelay = true;
function moveObjects() {
earthMoon.move();
moon.move();
sunDelay = !sunDelay;
if (sunDelay) sun.move();
if (parseInt(moon.top) > parseInt(earth.top)) {
if (moon.zIndex != 1) moon.zIndex = 1;
} else {
if (moon.zIndex != 3) moon.zIndex = 3;
}
setTimeout("moveObjects()",speed)
}
</SCRIPT>
</HEAD>
<BODY TEXT="white" LINK="AQUA" VLINK="YELLOW" BACKGROUND="http://school.ciit.zp.ua/html-htm/dhtml/pic/stars.gif" onLoad="init()">
<SPAN ID="allSpan" STYLE="position:absolute; left:0; top:80; width:336; height:316;">
<SPAN ID="sunSpan" STYLE="position:absolute; left:131; top:90; width:71;">
<IMG id=s SRC="http://school.ciit.zp.ua/html-htm/dhtml/pic/sun.gif" WIDTH=71 HEIGHT=71 BORDER=0>
</SPAN>
<SPAN ID="earthMoonSpan" STYLE="position:absolute; left:232; top:72; width:100; height:100;">
<SPAN ID="earthSpan" STYLE="position:absolute; z-index:2; left:34; top:34; width:32; height:32;">
<IMG SRC="http://school.ciit.zp.ua/html-htm/dhtml/pic/earth.gif" WIDTH=32 HEIGHT=32 BORDER=0>
</SPAN>
<SPAN ID="moonSpan" STYLE="position:absolute; left:80; top:40; width:20; height:20;">
<IMG SRC="http://school.ciit.zp.ua/html-htm/dhtml/pic/moon.gif" WIDTH=20 HEIGHT=20 BORDER=0>
</SPAN>
</SPAN>
</SPAN>
<H2>Сложное движение элементов</H2>
<HR>
<P>
Солнце вращается по элиптической орбите вокруг некоторого центра.
Земля, в свою очередь, вращается вокруг Солнца также по эллиптической
орбите. Наконец, Луна вращается вокруг Земли, опять же, по
эллиптической орбите. И все это вращается одновременно! Траектория
Земли довольно замысловата, а уж о траектории Луны и говорить
нечего!<BR><BR>
<HR>
</P>
Идея этого примера принадлежит Дэну Стайнману. Настоящая
реализация — Е.П.Лилитко с использованием картинок Дэна
Стайнмана.
</BODY>
</HTML>
|
Цитата:
|
ТЕперь известно. Спасибо большооооооо:) ое
|
| Часовой пояс GMT +3, время: 18:09. |