it leader

2. 이미지 띄우기




starling에서 이미지를 띄우기 위해서는 동일하게


Starling Image 클래스를 생성하여야 한다.



var bitmapData : Bitmapdata = new BitmapData ( 100 , 100, false, 0xff0000);

var texture : Texture = Texture.fromBitmapData( bitmapData);    // fromBitmap 은  file을 불러올때

var image : Image = new Image( texture);                      // texture 클래스는 한장의 이미지를 불러올때 사용한다.

addChild(image);



bitmapData를 생성하고

Texture라는 클래스에 bitmapData를 담고

Image 클래스에 다시 Texture를 담는다




png 이미지를 로드 하려면


1. flash에서 png 이미지를 class로 등록한다

 ( SmliePng 라는 클래스 등록 )


2. libs 폴더에 넣는다.



public function GameMain()

{


var bitmapData :  BitmapData = new SmilePng();

var texture : Texture =Texture.fromtoBitmapData( bitmapData);

var image : Image = new Image ( texture);


addChild(image);


image.pivotX = 52;    // 객체의 중심점을 이동하는 매소드 pivotX, pivotY

image.pivotY = 52;

image.x = 150;

image.y  = 150;


image.addEventListener( Event.ENTER_FRAME, onEnter);


}


private function onEnter( e : Event) :void

{

image.rotation += 5;

}








profile

it leader

@dev__pixui

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!