我在这里有一个泡泡跳跃游戏,泡泡从游戏顶部落到底部,玩家尝试在30秒内弹出尽可能多的泡泡。这是一个三帧游戏,第一帧是开始按钮,第二帧是游戏,第三帧是比分,再次播放。 第一帧:进入第二帧的按钮 第二帧:计时器对30秒的播放时间进行计数 第三帧:再次播放的按钮。Actionscript 3.0:从AS3类访问动态文本到游戏
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.
谢谢你的时间。
这通常只是一个警告,你有你的舞台上,你选择了一个非系统字体的动态文本框。你的问题到底是什么?尝试导入MouseEvent(如果这是你的错误):import flash.events.MouseEvent; – Randalfien 2012-04-04 16:41:07
**错误1120:访问未识别的属性scoreValue **意味着您在某个时刻缺少文本字段。请记住,在您调用其方法时,您拖到舞台上的对象必须在舞台上可用 - 稍后将它放在某个关键帧上也无济于事。 – weltraumpirat 2012-04-04 17:04:56