2
버튼이있는 메인 메뉴를 프로그래밍하려고합니다. MenuAchievementsButton이라는 클래스가 있고 생성자에서 문서 클래스의 스테이지 너비와 스테이지 높이가 전달됩니다. 추적 할 때 올바른 너비/높이입니다.as3 MovieClip이 제대로 크기 조정되지 않습니다.
버튼 높이를 100 단계로 높이려고 노력 중입니다. 높이 = 100 단계이지만 this.height = 스테이지 높이를 시도했지만 시도 할 때마다 원하는 결과가 4 배가됩니다. 심지어 5와 같은 숫자를 입력하고 Photoshop에서 픽셀을 측정 할 때도 마찬가지입니다.
개체를 이동하려고해도 비슷한 문제가 있습니다. 예를 들어 20px로하고 싶을 때는 왼쪽/아래로 80px가됩니다.
도움을 주시면 감사하겠습니다.
package menus {
import flash.display.MovieClip;
public class MenuAchievementsButton extends MovieClip {
private var _stageWidth, _stageHeight:int;
public function MenuAchievementsButton(stageWidth:int, stageHeight:int) {
_stageWidth = stageWidth;
_stageHeight = stageHeight;
alpha = 1;
rescaleMe();
repositionMe();
trace(_stageWidth, _stageHeight);
}
private function rescaleMe():void {
var oldWidth = this.width;
var oldHeight = this.height;
this.height = _stageHeight/100;
this.width = (this.height * oldWidth)/oldHeight;
}
private function repositionMe():void {
this.x = 20;
this.y = 20;
trace(x,y,width,height);
trace("Stage height is: ",_stageHeight,"Stage height divided by 100 is: ", _stageHeight/100, "And the object's height, which should be stageheight/100 is:", this.height);
//Gives Stage height is: 800 Stage height divided by 100 is: 8 And the object's height, which should be stageheight/100 is: 8
//Actually, though, it's 36px!
}
}
}
내가 scaleX가 = 1을하려고, 그것이 더 큰 수 :이 같은 부모의 규모, 뭔가를 변경하지 않으면
을 참조하십시오! 나는 검사했다, 목표물이 무대 또는 다른 대상체에 있지 않다 ... 어떤 생각인가? – DefinitelyNotAPlesiosaur
해결책을 찾았습니다 - 크기가 조정 된 기본 메뉴 배경에서 단추를 만들었습니다. 도와 주셔서 감사합니다! : D – DefinitelyNotAPlesiosaur
@ user2696186 예, 스케일링은 항상 전역이 아닌 상위를 기준으로합니다. – Vesper