Comentario: Puede usar HTML5 para imitar el sistema operativo de Apple para hacer un iOS que pueda ejecutarse en la plataforma web. Tengamos algo de entretenimiento hoy y comencemos una interfaz de arranque. Los amigos interesados pueden referirse a él. Espero que sea útil para todos.
Hoy pensé de repente en usar HTML5 para imitar el sistema operativo de Apple para hacer un iOS que pueda ejecutarse en la plataforma web.Por supuesto, tengo que desarrollar un sistema operativo, y hablaré de ello después de regresar a las montañas por otros cien años de práctica. Tomemos algo de entretenimiento hoy y comencemos una interfaz de arranque.
Fotos completadas:
Me preocupa que la imagen sea psed por mí, y puedo ingresar directamente la siguiente prueba de dirección:
Dado que Lufylegend está bien empaquetado, este desarrollo aún se realiza con este motor. No hay mucho código, y los amigos interesados pueden echar un vistazo directamente.
Código en index.html:
<! Doctype html>
<html>
<Evista>
<meta charset = "utf-8" />
<title> iPhone </title>
<script src = "./ lufylegend-1.7.7.min.js"> </script>
<script src = "./ js/main.js"> </script>
</ablo>
<Body>
<Div> Carga ... </div>
</body>
</html>
Código en main.js:
init (50, "mylegend", 450,640, principal);
Lglobal.setDebug (verdadero);
var LoadData = [
{ruta: "./ js/shape.js", tipo: "js"},
{ruta: "./ js/bootpage.js", tipo: "js"},
{nombre: "Wallpaper", ruta: "./ Images/wall_paper.jpg"}
];
var dataList = {};
Var Backlayer, iPhonElayer, ScreenLapeer, Buttonlayer;
var iosshape;
VAR PAPACIÓN DE BOOT;
función main () {
LloadManage.load (LoadData, Null, GameInit);
}
function gameInit (resultado) {
dataList = resultado;
// Capa de inicialización
initlayer ();
// Agregar una caja de iPhone
addShape ();
// Agregar a la interfaz de arranque
addback ();
}
función initlayer () {
// Capa de fondo
backlayer = new Lsprite ();
AddChild (Backlayer);
}
función addshape () {
iosshape = nueva forma ("iPhone", 400,600);
iosshape.x = 15;
iosshape.y = 5;
backlayer.addchild (Iosshape);
}
función addback () {
bootpage = new BootPage ();
bootpage.x = 40;
bootpage.y = 40;
var wallpaperwidth = iosshape.getScreenWidth ();
var wallpaperHeight = iosshape.getScreenHeight ();
bootpage.addwallpaper (nuevo LBITMAPDATA (Datalist ["Wallpaper"], 200,480, WallpaperWidth, WallpaperHeight));
bootpage.addtime ();
BootPage.addsLider ();
iosshape.addchild (página de arranque);
}
Código en forma.js:
/*
* Forma.js
**/
forma de función (tipo, ancho, altura) {
var s = esto;
base (s, lsprite, []);
sx = 0;
sy = 0;
S.DeviceWidth = ancho;
S.DeviceHeight = altura;
s.type = type;
// Capa de casos
s.shapelayer = new Lsprite ();
S.Addchild (S.Shapelayer);
// Capa de botones de inicio
S.Homebuttonlayer = new Lsprite ();
S.Addchild (S.Homebuttonlayer);
// capa de pantalla
S.ScreenLayer = new Lsprite ();
S.Addchild (S.Screenlayer);
// Muéstrate a ti mismo
s._showself ();
}
Shape.prototype._showself = function () {
var s = esto;
Switch (S.Type) {
estuche "iPhone":
// Dibuja el caparazón
Var Shadow = new ldropShadowFilter (15,45, "negro", 20);
S.Shapelayer.Graphics.Drawroundrect (10, "Negro", [0,0, S.DeviceWidth, S.DeviceHeight, 15], verdadero, "Negro");
s.shapelayer.filters = [Shadow];
// Dibuja la pantalla
S.Screenlayer.Graphics.Drawrect (0, "Black", [S.DeviceWidth/10, S.DeviceWidth/10, S.DeviceWidth*0.8, s.deviceheight*0.8], verdadero, "blanco");
// Dibuja el botón de inicio
S.Homebuttonlayer.Graphics.Drawarc (1, "Black", [S.DeviceWidth/2, S.DeviceHeight*0.87 + S.DeviceWidth/10, S.DeviceWidth/16,0,2*Math.pi], True, "#191818");
S.Homebuttonlayer.Graphics.Drawroundrect (3, "White", [S.DeviceWidth/2-10, S.DeviceHeight*0.87 + S.DeviceWidth/10 - 10,20,20,5]);
romper;
}
};
Shape.prototype.getScreenWidth = function () {
var s = esto;
return s.DeviceWidth*0.8;
};
Shape.prototype.getScreenHeight = function () {
var s = esto;
regresar S.DeviceHeight*0.8
};
Finalmente, está el código en BootPage.js:
/*
* Bootpage.js
**/
function bootPage () {
var s = esto;
base (s, lsprite, []);
sx = 0;
sy = 0;
s.timelayer = new Lsprite ();
S.SliderLayer = new Lsprite ();
}
Bootpage.prototype.addwallpaper = function (bitmapData) {
var s = esto;
// Agregar una imagen de fondo
s.wallpaper = new LbitMap (bitmapData);
S.Addchild (S.wallpaper);
};
Bootpage.prototype.addtime = function () {
var s = esto;
var shadow = new ldropShadowFilter (1,1, "negro", 8);
S.Addchild (S.Timelayer);
S.Timelayer.Graphics.Drawrect (0, "", [0,0, iosshape.getScreenWidth (), 150], verdadero, "negro");
// Agregar al área de texto de tiempo
S.Timelayer.alpha = 0.3;
S.TimEtext = new lTextField ();
s.timetext.x = 70;
S.Timetext.y = 20;
S.Timetext.size = 50;
s.timetext.color = "White";
S.Timetext.weight = "Bold";
s.timetext.filters = [shadow];
// Agregar fecha de texto de fecha
s.datetext = new lTextField ();
s.datetext.size = 20;
s.datetext.x = 110;
s.datetext.y = 100;
s.datetext.color = "white";
s.datetext.weight = "Bold";
s.datetext.filters = [shadow];
S.Addchild (S.Timetext);
S.Addchild (s.datetext);
// Fecha de actualización a través del evento de línea de tiempo
S.AdDeventListener (levent.enter_frame, function (s) {
var fecha = nueva fecha ();
if (date.getMinutes () <10) {
if (date.gethours () <10) {
s.timetext.text = "0" + date.gethours () + ": 0" + date.getminutes ();
}demás{
s.timetext.text = date.gethours () + ": 0" + date.getminutes ();
}
}demás{
if (date.gethours () <10) {
s.timetext.text = "0" + date.gethours () + ":" + date.getminutes ();
}demás{
s.timetext.text = date.gethours () + ":" + date.getminutes ();
}
}
s.datetext.text = date.getMonth () + 1 + "mes" + date.getDate () + "día";
})
};
Bootpage.prototype.addslider = function (bitmapData) {
var s = esto;
S.Addchild (S.Sliderlayer);
s.sliderlayer.graphics.drawrect (0, "", [0, iosshape.getScreenHeight ()-100, iosshape.getScreenWidth (), 100], verdadero, "negro");
S.Sliderlayer.alpha = 0.3;
// Agregar capa del marco deslizante
var Barbler = new Lsprite ();
Barbler.x = 35;
Barbler.y = iosshape.getScreenHeight ()-70;
S.Addchild (Barbler);
// Agregar instrucciones de control deslizante
var MoveBarCommont = new lTextField ();
MoveBarCommont.Size = 12;
MoveBarCommont.x = 80;
MoveBarCommont.y = 10;
MoveBarCommont.color = "White";
MoveBarCommont.Text = "Slide para desbloquear.";
Barbler.addchild (MovBarcommont);
// Agregar capa deslizante
var bar = new lsprite ();
bar.x = 35;
bar.y = iosshape.getScreenHeight ()-70;
bar.canmoveBar = false;
// Agregar eventos de movimiento del mouse y movimiento del mouse
bar.addeventListener (lMouseEvent.Mouse_Down, Function (Event, S) {
S.CanmoveBar = True;
});
bar.addeventListener (lMouseEvent.Mouse_Up, Function (Event, S) {
LteweLite.to (bar, 0.5, {
X: 35,
onComplete: function (s) {
s.canmoveBar = false;
}
});
s.canmoveBar = false;
});
S.Addchild (bar);
bar.addeventListener (lMouseEvent.Mouse_out, Function (Event, S) {
LteweLite.to (bar, 0.5, {
X: 35,
onComplete: function (s) {
s.canmoveBar = false;
}
});
s.canmoveBar = false;
});
S.AdDeventListener (lMouseEvent.Mouse_Move, function (evento) {
if (bar.canmovebar == true) {
bar.x = event.offsetx - 70;
if (bar.x> 215) {bar.x = 215;}
if (bar.x <35) {bar.x = 35;}
}
});
S.Addchild (bar);
// Dibuja la caja del control deslizante
Barbler.Graphics.Drawroundrect (2, "#191818", [0,0,250,40,5], verdadero, "negro");
Barbler.alpha = 0.7;
// Dibuja el control deslizante
bar.Graphics.Drawroundrect (2, "Dimgray", [0,0,70,40,5], verdadero, "LightGray");
bar.alpha = 0.7;
};
Desde esta vez, me estoy entreteniendo, no hablaré más sobre el código, solo hablaré sobre los usos de Shape.js y BootPage.js. Shape.js es una clase utilizada para dibujar el shell de nuestro teléfono iPhone, mientras que BootPage.js es una clase para la interfaz de arranque. Las funciones de los dos son diferentes, lo que es equivalente a la forma. JS se usa para manejar la apariencia del hardware y la página de arranque. JS se usa para manejar la pantalla.
Dejemos el resto para que lo vea. Aunque el código es un poco largo, no es lógico. ¡Léelo lentamente! Por supuesto, los estudiantes que no pueden entender pueden no haber entendido Lufylegend. El siguiente es el sitio web oficial del motor:
Documentación de la API del motor:
Los estudiantes que sienten que es difícil leer códigos con blogs CSDN, no usan su editor para abrir el código fuente y ver la dirección de descarga del código fuente de la siguiente manera: