我这里有一个泡泡弹出游戏,其中气泡从游戏顶部落到底部,玩家尝试在30秒内弹出尽可能多的泡泡。这是一个3帧游戏,第1帧是开始按钮,第2帧是游戏,第3帧是得分并再次播放。 第1帧:进入第二帧的按钮 第二帧:计时器计算30秒的播放时间 第3帧:再次播放的按钮。
ScoreValue是游戏最后一帧中的动态文本框。它根据气泡的大小比例大小记录点数,并应根据玩家弹出的气泡量进行更改。
scoreValue.text = score.toString();
Error 1120: Access of unidentified property scoreValue
无论如何在这里完整的代码包。
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.media.Sound;
import flash.geom.ColorTransform;
public class Ball extends MovieClip{
static public var burstCounter: uint;
private var vx: Number;
private var vy: Number;
private var gravity: Number;
private var stageWidth;
private var stageHeight;
private var bubble:Ball = new Ball();
private var score: uint=0;
public function Ball() {
bubble.addEventListener(Event.ADDED_TO_STAGE, initialize)
bubble.addEventListener(MouseEvent.CLICK, burst)
bubble.addEventListener(Event.ENTER_FRAME, dropping)
}
public function initialize (e:Event):void
{
bubble.x = Math.random() * stageWidth;
bubble.y = 0;
stageWidth = stage.stageWidth;
stageHeight = stage.stageHeight;
bubble.vx = Math.random() * 2 - 1;
bubble.vy = Math.random() * 2 + 1;
gravity = 0.1;
var sizeScale = Math.random() * 1.2 + .6;
bubble.scaleX = bubble.scaleY = sizeScale;
score = (10 / sizeScale);
scoreValue.text = score.toString();
var colorTran = new ColorTransform();
colorTran.color = Math.random() * 0xFFFFFF;
transform.colorTransform = colorTran;
addChild(bubble);
}
function dropping(e: Event) :void
{
x += vx;
y += vy;
vy += gravity;
if((x<0) || (x>stageWidth) || (y<0) || (y>stageHeight))
{
if(parent != null)
{
parent.removeChild(this);
}
removeEventListener(Event.ENTER_FRAME, dropping)
}
}
function burst (e:Event):void
{
var ballonPopping: Sound = new BalloonPopping();
bubble.removeEventListener(Event.ADDED_TO_STAGE, initialize);
bubble.removeEventListener(Event.ENTER_FRAME, dropping);
removeChild(bubble);
ballonPopping.play();
burstCounter += score;
}
}
}
我在程序中将其作为输出,有人知道为什么吗?
Fonts should be embedded for any text that may be edited at runtime, other than text with the "Use Device Fonts" setting. Use the Text > Font Embedding command to embed fonts.
感谢您的时间。
答案 0 :(得分:1)
您需要导入MouseEvent类来修复“访问MouseEvent的未定义属性”
将此内容添加到导入语句中:
import flash.events.MouseEvent;
答案 1 :(得分:0)
首先,在课堂上,函数应定义为public
或private
。其次,当您为burst
分配Event
时,MouseEvent
函数需要private function burst (e:MouseEvent):void
。这是我经常使用的一个容易犯的错误。
将其更改为:
import flash.events.*;
输出面板中的字体意味着您在某处有动态文本字段。只需转到FLA,打开该文本字段,然后在属性面板上点击嵌入按钮,选择Basic Latin复选框...或数字(如果只是数字)
编辑:同时将导入更改为
import flash.events.MouseEvent;
或添加
{{1}}