2. Cómo hacer aplicaciones y
videojuegos 3D para Flash Player 11
con Flare3D
Adrian Simonovich
Ariel Nehmad
José Luis Ressia
3.
4. Configurando nuestra IDE para trabajar con
Stage3D y Flash Player 11
• Flash Player 11
• Flash Player 11 playerglobal.swc
• Adobe Flex SDK 4.5.1
• Flare3D (descargar desde www.flare3d.com)
• IDE de su preferencia.
5. Cargando modelos 3D en Flash
• Scene3D
var scene:Scene3D = new Scene3D(container);
• Pivot3D
var astronaut:Pivot3D = scene.addChildFromFile( "astronaut.f3d“)
• Eventos
scene.addEventListener( Scene3D.PROGRESS_EVENT, progressEvent );
scene.addEventListener( Scene3D.COMPLETE_EVENT, completeEvent );
6. Definir el comportamiento de los objetos en la escena
• Las cosas por su nombre - getChildByName(“Objeto”)
sky = planet.getChildByName( "sky" );
• planet.forEach( setupScene );
private function setupScene( pivot:Pivot3D ):void
{
if ( pivot.name == "fan" ){….}
}
• private function updateEvent(e:Event):void
{ // Update the world.
}
7. Posicionando la cámara
• Como posicionar un objeto en un entorno 3D
Pivot3DUtils.setPositionWithReference( scene.camera, 0, 80, -20,
container, 0.1 );
• Pivot3DUtils.lookAtWithReference( scene.camera, 0, 0, 0, container,
container.getDir(), 0.05 );
8. Controlando al astronauta
• Detección de teclas
• Input3D.keyDown()
• Input3D.keyHit()
• Rayos
Un rayo es una linea virtual infinita que comienza en un punto
arbitrario y continua infinitamente en una dirección
• ray = new RayCollision();
• ray.addCollisionWith( planet.getChildByName( "floor" ), false );
9. Controlando al astronauta
• Test del rayo
if ( ray.test( from, dir ) )
{
// Get the info of the first collision.
var info:CollisionInfo = ray.data[0];
// Set the astronaut container at the collision point.
container.setPosition( info.point.x, info.point.y, info.point.z );
// Align the astronaut container to the collision normal.
container.setNormalOrientation( info.normal, 0.05 );
10. Detectando colisiones con obstaculos
• SphereCollision
private var collisions:SphereCollision;
Creando la colision
collisions = new SphereCollision( container, 3, new Vector3D( 0, 3, 0 ) );
• Agregando la colision con objetos
collisions.addCollisionWith( pivot, false );
• Detectando la colision
collisions.slider();
12. Controlando los movimientos del personaje
• Control de estados
- run
- jump
• Método GameLogics
switch( state )
{
case "run":
if ( Input3D.keyHit( Input3D.SPACE ) )
{ jumpValue = 4;
fireEmiter.emitParticlesPerFrame = 25;
container.gotoAndPlay( "jump", 3 );
}
break;
}
13. Agregando peligros al juego
• Flash Player 11
• Flash Player 11 playerglobal.swc
• Adobe Flex SDK 4.5.1
• Flare3D (descargar desde www.flare3d.com)
• IDE de su preferencia.