FlashDevelop를 사용하여 게임에 사용할 메뉴 유형 시스템을 테스트하고 있는데 너비 및 높이를 파악하는 데 심각한 문제가 있거나 Sprite 하위 클래스의 ScaleX 및 ScaleY (어떤 세트가 문제를 일으키는 지 잘 모르겠습니다). 나는 아이들을 추가 한 후에 스프라이트 서브 클래스의 크기를 조절하는 것을 포함하여 내 문제의 해결책 인 것 같은 많은 것들을 읽었지만 아무 것도 작동하지 않는 것 같다. 지금 당장에는 3 개의 클래스가 있습니다.AS3 : ScaleX/ScaleY 및 너비/높이 문제
홈페이지 :
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var BF:BFi = new BFi;
this.addChild(BF);
this.width = 640;
this.height = 480;
trace(this + "Dimensions: " + width + ", " + height);
trace(this + "Coordinates: " + x + ", " + y);
}
}
BFI :
public class BFi extends Sprite
{
public function BFi()
{
var BFMenu:BFiMenu = new BFiMenu;
addChild(BFMenu);
trace(getChildAt(0));
this.x = this.y = 0;
this.width = 640;
this.height = 480;
BFMenu.x = this.y = 0;
BFMenu.width = 640;
BFMenu.height = 480;
trace(this + "Dimensions: " + width + ", " + height);
trace(this + "Coordinates: " + x + ", " + y);
}
}
및 BFiMenu :
public class BFiMenu extends Sprite
{
[Embed(source = "../Assets/Button1.png")]private var Button1:Class;
public function BFiMenu()
{
var Bounds:Sprite = new Sprite;
Bounds.graphics.lineStyle(2, 0, 1);
Bounds.graphics.drawRect(0, 0, 640, 480);
addChild(Bounds);
var NewButton:ComplexButton = new ComplexButton(220, 405, 200, 50, Button1, "PLAY", "Block", 50, 0x000000, function Button1(e:MouseEvent):void { /*parent.removeChildAt(0);*/ });
//var NewButton:ComplexButton = new ComplexButton(0, 0, 200, 50, Button1, "PLAY", "Block", 50, 0x000000, function Button1(e:MouseEvent):void { parent.removeChildAt(0); });
addChild(NewButton);
this.width = 640;
this.height = 480;
trace(this + "Dimensions: " + width + ", " + height);
trace(this + "Coordinates: " + x + ", " + y);
trace(NewButton + "Dimensions: " + NewButton.width + ", " +NewButton.height);
trace(NewButton + "Coordinates: " + NewButton.x + ", " + NewButton.y);
}
}
"경계"라는 이름의 사각형은 내가 원하는 걸의 높이와 폭 (640 × 480)가 , 내가 넣은 버튼은 약 450의 y 좌표를 가지고 있다고 가정하고, 대신에 거의 800의 y 값을 가지며 분명히 dis 비록 높이가 단지 480인데도 화면 상에 왜곡되어있다.
호출되는 "ComplexButton"클래스는 내 자신의 버튼 클래스이며 제대로 작동하는지 충분히 테스트했다. 이 프로그램을 실행하면 모든 것을 왜곡하고 내가 원하는 곳이 없습니다. 어떤 도움을 주시면 감사하겠습니다.
모양과 모양이 어울리는 사진을 제공 할 수 있습니까? 또한 스케일링 할 코드 –