简体   繁体   中英

Actionscript 3 game Character (Flashdevelop)

I am currently trying to make a game in Flashdevelop. The language I am using is Actionscript 3.

How can I implement my design for the character? I tried to embed the image file, but flashdevelop gives me errors.

public class Player extends MovieClip 
    {
        [Embed(source="../Images/Main Character.png")]
        public var floor:int = 684;

This is the error: An Embed variable must not have an existing value.

Add next code after Embed tag:

public var MainCharacter:Class;

To add this image to the stage write:

var bmp:Bitmap = new MainCharacter() as Bitmap;
addChild(bmp);

There's really no need for MovieClip here, just extend Sprite if you need a container.

If you do not want to create another child like @subdan shows in his answer, you can tie the class directly to the embedded content, by placing the embed line right above the class line:

[Embed(source="../Images/Main Character.png")]
public class Player extends Bitmap 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM