How do I setup a game room in pure actionscript?

时间秒杀一切 提交于 2019-12-13 09:39:28

问题


Height, Width, Background Color, placing objects in the room and such. Can anyone help me?


回答1:


Read the manual. Seriously.




回答2:


// An 800x600 black room with a red ball, you say?..
//
// This is written & tested in Flash CS4.
// Hopefully you just need some sample code to explore,
// also I recommend geting familiar with the AS3 language reference:
//   http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/

// Background: a black rectangle.
var background:Sprite = new Sprite();
with( background.graphics ) {
    beginFill( 0x000000, 1.0 );
    drawRect( 0, 0, 800, 600 );
    endFill();
}
addChild( background ); // add it to the stage

// Red ball.
var ball:Sprite = new Sprite();
with( ball.graphics ) {
    beginFill( 0xff0000, 1.0 );
    drawCircle( 0, 0, 100 );
    endFill();
}
addChild( ball );

// Start the ball in the center of the room
ball.x = 400;
ball.y = 300;

// When we click the ball, move it to a new location.
ball.addEventListener( MouseEvent.CLICK, moveBall );

function moveBall( e:MouseEvent ) :void {
    ball.x = Math.random() * 800;
    ball.y = Math.random() * 600;
}

// Hope this helps... Flash & Actionscript 3 is a very rich environment,
// there's a lot to learn & discover. I learn new tricks with each project.



回答3:


Create a sprite. var room:Sprite = new Sprite();

Get the graphics object. var g:Graphics = room.graphics;

Draw:

g.beginFill(0xFF0000, 1);

g.drawRect(0,0,800,600);

g.endFill();

Rinse and repeat. Children are added to "room" via room.addChild(chair);, but they're created the same way.

There are lots of tutorials out there for how to start up a simple project.

http://www.senocular.com/flash/tutorials/as3withmxmlc/ http://www.senocular.com/flash/tutorials.php




回答4:


If you use the free opensource IDE FlashDevelop, then you can just set the properties in the properties panel.

If you have a pure actionscript project you can use the SWF meta tag to define stage properties:

[SWF(width='800', height='600', backgroundColor='#000000', frameRate='30')]

Without more info, I can't really answer much more than that.




回答5:


The first two articles of the Flash Adventure Game Tutorial, Creating a level and Loading a level, show you how to create a 2D map with free TaT level editor and then display it in a Flash game. Later articles cover adding items to the level and then loading them into a game.



来源:https://stackoverflow.com/questions/1569385/how-do-i-setup-a-game-room-in-pure-actionscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!