SlideShare a Scribd company logo
Developing 2D Games with Stage3D
Developing 2D Games with Stage3D
Developing 2D Games with Stage3D
•

•

•

•

•
Developing 2D Games with Stage3D
•

•

•
•

    •
    •
    •
    •
Developing 2D Games with Stage3D
•

•

•

•
Developing 2D Games with Stage3D
// create the vertices
varvertices:Vector.<Number> = Vector.<Number>([
-0.5,-0.5,0, 0, 0, // x, y, z, u, v
-0.5, 0.5, 0, 0, 1,
0.5, 0.5, 0, 1, 1,
0.5, -0.5, 0, 1, 0]);
// create the buffer to upload the vertices
var vertexbuffer:VertexBuffer3D = context3D.createVertexBuffer(4, 5);
// upload the vertices
vertexbuffer.uploadFromVector(vertices, 0, 4);
// create the buffer to upload the indices
var indexbuffer:IndexBuffer3D = context3D.createIndexBuffer(6);
// upload the indices
indexbuffer.uploadFromVector (Vector.<uint>([0, 1, 2, 2, 3, 0]), 0, 6);
// create the bitmap texture
varbitmap:Bitmap = new TextureBitmap();
// create the texture bitmap to upload the bitmap
vartexture:Texture = context3D.createTexture(bitmap.bitmapData.width,
bitmap.bitmapData.height, Context3DTextureFormat.BGRA, false);
// upload the bitmap
texture.uploadFromBitmapData(bitmap.bitmapData);
// create the mini assembler
varvertexShaderAssembler :AGALMiniAssembler = new AGALMiniAssembler();
// assemble the vertex shader
vertexShaderAssembler.assemble( Context3DProgramType.VERTEX,
"m44 op, va0, vc0n" + // pos to clipspace
"mov v0, va1" // copy uv
);
varfragmentShaderAssembler :AGALMiniAssembler = new AGALMiniAssembler();
// assemble the fragment shader
fragmentShaderAssembler.assemble( Context3DProgramType.FRAGMENT,
"tex ft1, v0, fs0 <2d,linear, nomip>;n" +
"movoc, ft1"
);
// create the shader program
var program:Program3D = context3D.createProgram();
// upload the vertex and fragment shaders
program.upload( vertexShaderAssembler.agalcode, fragmentShaderAssembler.agalcode);
// clear the buffer
context3D.clear ( 1, 1, 1, 1 );
// set the vertex buffer
context3D.setVertexBufferAt(0, vertexbuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
context3D.setVertexBufferAt(1, vertexbuffer, 3, Context3DVertexBufferFormat.FLOAT_2);
// set the texture
context3D.setTextureAt( 0, texture );
// set the shaders program
context3D.setProgram( program );
// create a 3D matrix
var m:Matrix3D = new Matrix3D();
// apply rotation to the matrix to rotate vertices along the Z axis
m.appendRotation(getTimer()/50, Vector3D.Z_AXIS);
// set the program constants (matrix here)
context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, m, true);
// draw the triangles
context3D.drawTriangles(indexbuffer);
// present the pixels to the screen
context3D.present();
// create a Texture object out of an embedded bitmap
var _texture:Texture = Texture.fromBitmap ( new EmbeddedBitmap() );

// create an Image object our of the Texture
var _image:Image = new Image(_texture);

// set the properties
_image.pivotX = 50;
_image.pivotY = 50;
_image.x = 300;
_image.y = 150;
_image.rotation = Math.PI/4;

// display it
addChild(_image);
Developing 2D Games with Stage3D
Developing 2D Games with Stage3D
Developing 2D Games with Stage3D
Developing 2D Games with Stage3D
Developing 2D Games with Stage3D

More Related Content

PDF
MongoUK - PHP Development
PDF
JavaSE7 Launch Event: Java7xGroovy
PDF
Зависимые типы в GHC 8. Максим Талдыкин
DOCX
PPT
Full-Stack JavaScript with Node.js
PDF
刘平川:【用户行为分析】Marmot实践
PPTX
The State of JavaScript
MongoUK - PHP Development
JavaSE7 Launch Event: Java7xGroovy
Зависимые типы в GHC 8. Максим Талдыкин
Full-Stack JavaScript with Node.js
刘平川:【用户行为分析】Marmot实践
The State of JavaScript

What's hot (20)

PDF
用户行为系统Marmot - D2 2011 session
PDF
言語の設計判断
PPTX
The jsdom
PDF
MongoDBで作るソーシャルデータ新解析基盤
PDF
MongoDB Oplog入門
PDF
MongoDB全機能解説2
TXT
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
PDF
FrozenRails Training
PPTX
Azure Durable Funkiness - .NET Oxford June 2018
PDF
C++ Programming - 7th Study
PDF
C++ Programming - 8th Study
TXT
Litebox
PDF
Interactive subway map
PDF
Debugging: Rules And Tools - PHPTek 11 Version
PDF
Redis the better NoSQL
PDF
C++ Programming - 6th Study
PPTX
Super Advanced Python –act1
PDF
MySQL Create Table
PDF
Node lt
PDF
Exploring fractals in CSS, @fronttrends, Warsaw, 2015
用户行为系统Marmot - D2 2011 session
言語の設計判断
The jsdom
MongoDBで作るソーシャルデータ新解析基盤
MongoDB Oplog入門
MongoDB全機能解説2
Tipo virus espia con esto aprenderan a espiar a personas etc jeropas de mrd :v
FrozenRails Training
Azure Durable Funkiness - .NET Oxford June 2018
C++ Programming - 7th Study
C++ Programming - 8th Study
Litebox
Interactive subway map
Debugging: Rules And Tools - PHPTek 11 Version
Redis the better NoSQL
C++ Programming - 6th Study
Super Advanced Python –act1
MySQL Create Table
Node lt
Exploring fractals in CSS, @fronttrends, Warsaw, 2015
Ad

Similar to Developing 2D Games with Stage3D (20)

PDF
Stage3D and AGAL
PPTX
Mochi London 2011
ZIP
Adobe AIR: Stage3D and AGAL
PDF
WebGL - 3D in your Browser
PDF
Neurotech Solutions Ltd: Рекомендации по Stage3D: выбор наиболее подходящего ...
PPTX
Introduction to open gl in android droidcon - slides
PPTX
FGS 2011: Flash+ A Whole New Dimension for Games
PPT
Advanced Game Development with the Mobile 3D Graphics API
PDF
Getting Started with 3D Game Development on Nokia Series 40 Asha Phones
PDF
WPF L03-3D Rendering and 3D Animation
PDF
Starling基于stage3 d开发gpu加速的2d游戏
TXT
Flare3d jiglib.as
PDF
2011.05.27 ACC 기술세미나 : Adobe Flash Builder 4.5를 환경에서 Molehill 3D를 이용한 개발 소개
KEY
openFrameworks 007 - 3D
PDF
XNA L04–Primitives, IndexBuffer and VertexBuffer
KEY
openFrameworks 007 - GL
PDF
Three.js basics
PDF
3D everywhere
PDF
WebGL 3D player
PDF
"Graphical fun With WebGL shaders", Martin Splitt
Stage3D and AGAL
Mochi London 2011
Adobe AIR: Stage3D and AGAL
WebGL - 3D in your Browser
Neurotech Solutions Ltd: Рекомендации по Stage3D: выбор наиболее подходящего ...
Introduction to open gl in android droidcon - slides
FGS 2011: Flash+ A Whole New Dimension for Games
Advanced Game Development with the Mobile 3D Graphics API
Getting Started with 3D Game Development on Nokia Series 40 Asha Phones
WPF L03-3D Rendering and 3D Animation
Starling基于stage3 d开发gpu加速的2d游戏
Flare3d jiglib.as
2011.05.27 ACC 기술세미나 : Adobe Flash Builder 4.5를 환경에서 Molehill 3D를 이용한 개발 소개
openFrameworks 007 - 3D
XNA L04–Primitives, IndexBuffer and VertexBuffer
openFrameworks 007 - GL
Three.js basics
3D everywhere
WebGL 3D player
"Graphical fun With WebGL shaders", Martin Splitt
Ad

Recently uploaded (20)

PPTX
Programs and apps: productivity, graphics, security and other tools
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
KodekX | Application Modernization Development
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Programs and apps: productivity, graphics, security and other tools
“AI and Expert System Decision Support & Business Intelligence Systems”
Unlocking AI with Model Context Protocol (MCP)
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
20250228 LYD VKU AI Blended-Learning.pptx
Spectroscopy.pptx food analysis technology
Understanding_Digital_Forensics_Presentation.pptx
KodekX | Application Modernization Development
MYSQL Presentation for SQL database connectivity
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

Developing 2D Games with Stage3D

  • 7. • • • •
  • 11. // create the vertices varvertices:Vector.<Number> = Vector.<Number>([ -0.5,-0.5,0, 0, 0, // x, y, z, u, v -0.5, 0.5, 0, 0, 1, 0.5, 0.5, 0, 1, 1, 0.5, -0.5, 0, 1, 0]); // create the buffer to upload the vertices var vertexbuffer:VertexBuffer3D = context3D.createVertexBuffer(4, 5); // upload the vertices vertexbuffer.uploadFromVector(vertices, 0, 4); // create the buffer to upload the indices var indexbuffer:IndexBuffer3D = context3D.createIndexBuffer(6); // upload the indices indexbuffer.uploadFromVector (Vector.<uint>([0, 1, 2, 2, 3, 0]), 0, 6); // create the bitmap texture varbitmap:Bitmap = new TextureBitmap(); // create the texture bitmap to upload the bitmap vartexture:Texture = context3D.createTexture(bitmap.bitmapData.width, bitmap.bitmapData.height, Context3DTextureFormat.BGRA, false); // upload the bitmap texture.uploadFromBitmapData(bitmap.bitmapData); // create the mini assembler varvertexShaderAssembler :AGALMiniAssembler = new AGALMiniAssembler(); // assemble the vertex shader vertexShaderAssembler.assemble( Context3DProgramType.VERTEX, "m44 op, va0, vc0n" + // pos to clipspace "mov v0, va1" // copy uv );
  • 12. varfragmentShaderAssembler :AGALMiniAssembler = new AGALMiniAssembler(); // assemble the fragment shader fragmentShaderAssembler.assemble( Context3DProgramType.FRAGMENT, "tex ft1, v0, fs0 <2d,linear, nomip>;n" + "movoc, ft1" ); // create the shader program var program:Program3D = context3D.createProgram(); // upload the vertex and fragment shaders program.upload( vertexShaderAssembler.agalcode, fragmentShaderAssembler.agalcode); // clear the buffer context3D.clear ( 1, 1, 1, 1 ); // set the vertex buffer context3D.setVertexBufferAt(0, vertexbuffer, 0, Context3DVertexBufferFormat.FLOAT_3); context3D.setVertexBufferAt(1, vertexbuffer, 3, Context3DVertexBufferFormat.FLOAT_2); // set the texture context3D.setTextureAt( 0, texture ); // set the shaders program context3D.setProgram( program ); // create a 3D matrix var m:Matrix3D = new Matrix3D(); // apply rotation to the matrix to rotate vertices along the Z axis m.appendRotation(getTimer()/50, Vector3D.Z_AXIS); // set the program constants (matrix here) context3D.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 0, m, true); // draw the triangles context3D.drawTriangles(indexbuffer); // present the pixels to the screen context3D.present();
  • 13. // create a Texture object out of an embedded bitmap var _texture:Texture = Texture.fromBitmap ( new EmbeddedBitmap() ); // create an Image object our of the Texture var _image:Image = new Image(_texture); // set the properties _image.pivotX = 50; _image.pivotY = 50; _image.x = 300; _image.y = 150; _image.rotation = Math.PI/4; // display it addChild(_image);

Editor's Notes

  • #4: Trust Lee to pick these images :p