好的,所以这显然是我在代码中愚蠢地忽略了的东西,但是我在 as3 中的布尔检查时遇到了问题。在下面的 if 语句中,我设置了一个布尔值,我可以确认在这个 if 开关中设置了布尔值,因为我已经运行了一个跟踪来检查:
if(switchA && switchB){
if(Side == "LEFT"){
localAttachCoords.x = (-Parent.collision.SideLength - entity.collision.SideLength)/2
localAttachCoords.y = Parent.collision.SideLength/2 - (((TargNode-1)*8) + entity.collision.SideLength/2)
}
if(Side == "RIGHT"){
localAttachCoords.x = (Parent.collision.SideLength + entity.collision.SideLength)/2
localAttachCoords.y = -(Parent.collision.SideLength/2 - (((TargNode-1)*8) + entity.collision.SideLength/2))
}
if(Side == "UP"){
localAttachCoords.y = (Parent.collision.SideLength + entity.collision.SideLength)/2
localAttachCoords.x = -(Parent.collision.SideLength/2 - (((TargNode-1)*8) + entity.collision.SideLength/2))
}
if(Side == "DOWN"){
localAttachCoords.y = (-Parent.collision.SideLength - entity.collision.SideLength)/2
localAttachCoords.x = Parent.collision.SideLength/2 - (((TargNode-1)*8) + entity.collision.SideLength/2)
}
entity.attached = true
entity.Parent = Parent
}
这一切都很好,但是因为在另一个类的函数中,每帧都执行,声称布尔值设置为 false,我用另一个跟踪函数证实了这一点。这是函数,取自entity
在上述开关中引用其实例的类:
public function update(){
if (physics) physics.update()
if (node && physics){
trace(attached)
if(attached){
physics.nodeUpdate()
}
}
}
此函数在附加 == false 的跟踪中声明,尽管它在前面设置为 true 而没有其他对附加变量的引用。任何帮助,将不胜感激!