FLASH AS3.0 代码问题1120: 访问的属性 Floor 未定义。
我copy了这段代码的一部分,问题是在if(mcisFloor){吗?完全不懂代码赶鸭子上架的请教各位大大!!package{importflash.display.*;...
我copy了这段代码的一部分,问题是在if (mc is Floor) { 吗? 完全不懂代码赶鸭子上架的请教各位大大!!
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.getTimer;
public class Game extends MovieClip {
static const gravity:Number = .004;
static const edgeDistance:Number = 200;
private var hero:Object;
private var fixedObjects:Array;
private var lastTime:Number = 0;
public function startGameLevel() {
createHero();
examineLevel();
this.addEventListener(Event.ENTER_FRAME,gameLoop);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
}
public function createHero() {
hero = new Object();
hero.mc = gamelevel.hero;
hero.dx = 0.0;
hero.dy = 0.0;
hero.inAir = false;
hero.direction = 1;
hero.animstate = "stand";
//hero.walkAnimation = new Array(2,3,4,5,6,7,8);
//hero.animstep = 0;
hero.jump = false;
hero.moveLeft = false;
hero.moveRight = false;
hero.jumpSpeed = .8;
hero.walkSpeed = .15;
hero.width = 20.0;
hero.height = 40.0;
hero.startx = hero.mc.x;
hero.starty = hero.mc.y;
}
public function examineLevel() {
fixedObjects = new Array();
for(var i:int=0;i<this.gamelevel.numChildren;i++) {
var mc = this.gamelevel.getChildAt(i);
if (mc is Floor) {
var floorObject:Object = new Object();
floorObject.mc = mc;
floorObject.leftside = mc.x;
floorObject.rightside = mc.x+mc.width;
floorObject.topside = mc.y;
floorObject.bottomside = mc.y+mc.height;
fixedObjects.push(floorObject);
}
}
} 展开
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.utils.getTimer;
public class Game extends MovieClip {
static const gravity:Number = .004;
static const edgeDistance:Number = 200;
private var hero:Object;
private var fixedObjects:Array;
private var lastTime:Number = 0;
public function startGameLevel() {
createHero();
examineLevel();
this.addEventListener(Event.ENTER_FRAME,gameLoop);
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
}
public function createHero() {
hero = new Object();
hero.mc = gamelevel.hero;
hero.dx = 0.0;
hero.dy = 0.0;
hero.inAir = false;
hero.direction = 1;
hero.animstate = "stand";
//hero.walkAnimation = new Array(2,3,4,5,6,7,8);
//hero.animstep = 0;
hero.jump = false;
hero.moveLeft = false;
hero.moveRight = false;
hero.jumpSpeed = .8;
hero.walkSpeed = .15;
hero.width = 20.0;
hero.height = 40.0;
hero.startx = hero.mc.x;
hero.starty = hero.mc.y;
}
public function examineLevel() {
fixedObjects = new Array();
for(var i:int=0;i<this.gamelevel.numChildren;i++) {
var mc = this.gamelevel.getChildAt(i);
if (mc is Floor) {
var floorObject:Object = new Object();
floorObject.mc = mc;
floorObject.leftside = mc.x;
floorObject.rightside = mc.x+mc.width;
floorObject.topside = mc.y;
floorObject.bottomside = mc.y+mc.height;
fixedObjects.push(floorObject);
}
}
} 展开
4个回答
展开全部
mc is Floor 就是mc这个变量是不是Floor类的一个对象,所以应该是你没有Floor类。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Floor未定义----------------Floor 肯定是写的一个类, 你没有这个类,或者没有用 import 来引用这个类
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1我看了1下,如果说你是写在针上,就不需要”private“。写上会报错。
写在包里要导入所用到TimerEvent的类。
2你的流程有问题,写清晰点。一个接一个执行。建议画下流程。
写在包里要导入所用到TimerEvent的类。
2你的流程有问题,写清晰点。一个接一个执行。建议画下流程。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
少了floor类
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询