ไม่ค่อยเข้าใจว่าชนแรง ๆ แบบไหนน่ะ
เอาเป็นลากแรง ๆ แล้วกัน
เพิ่ม 2 function
function startMove() {
this.startPointX = this._x;
this.startPointY = this._y;
this.startDrag();
delete this.onEnterFrame;
}
function stopMove() {
this.x = (this._x - this.startPointX)/3; // เปลี่ยนค่า /3 เป็นอื่น ๆ ก็ได้ ถ้าไม่ / มันจะวิ่งไวมาก ๆ
this.y = (this._y - this.startPointY)/3;
this.stopDrag();
this.onEnterFrame = animation;
}
แล้วก็แก้ function initStar เป็นตามนี้
function initStar(mc:MovieClip) {
mc.x = randRange(-15, 15); // กำหนดค่าที่จะเลื่อน ยังไม่ได้เลื่อนจริง ๆ นะ
mc.y = randRange(-15, 15);
mc.rotation = randRange(5,10); // กำหนดค่าที่จะหมุน
mc._alpha = randRange(20,100); // กำหนด alpha
mc._xscale = mc._yscale = randRange(100,100); // กำหนดขนาด
mc._x = randRange(0+(mc._width/2), Stage.width-(mc._width/2)); // กำหนดค่าเริ่มต้นที่จะวางใน stage
mc._y = randRange(0+(mc._height/2), Stage.height-(mc._height/2));
mc.onEnterFrame = animation; // กำหนดว่าให้ onEnterFrame ไปทำ function animation
mc.onPress = startMove;
mc.onRelease = mc.onReleaseOutside = stopMove;
}
// เพิ่ม 2 บรรทัดล่าง ให้กดที่ดาว และ ปล่อยดาว ทำอะไร
ลืมไปนิดนึง
mc._xscale = mc._yscale = randRange(100,100); // กำหนดขนาด
แก้เป็น 20, 100 นะ เมื่อกี้ แก้แ้ล้วลืมแก้กลับ
แบบนี้มันจะไม่ดีอยู่นิดนึงคือถ้าปาแรง ๆ มันจะวิ่งไม่หยุดเลยกดอีกทีลำบากมา
ควรไปแก้้ใน function animation ให้มันวิ่งช้าลงเรื่อย ๆ ด้วย แต่ขี้เกียจทำล่ะ