Hello there
I am simply testing one of my attempts.
I have got three movieclips with instance name “object”, “obstacle1” and “obstacle2”. I put the following codes in the first frame:
obstacles = ["obstacle0","obstacle1"]
numofObs = obstacles.length
for (i=0;i<numofObs;i++) {
obstacle = obstacles*
if (_root.obstacle.hitTest(_root.object)) {
_root.object.gotoAndStop(2)
_root.txt = "Collision is detected"
} else {
_root.object.gotoAndStop(1)
_root.txt = "No collision"
}
}
“object” should change from blue to red if it collides with “obstacle1” or “obstacle2”. I use the following codes to make “object” move:
onClipEvent (load) {
speed = 5
}
onClipEvent (enterFrame) {
if (Key.isDown (Key.RIGHT)) {
this._x += speed
} else if (Key.isDown (Key.LEFT)) {
this._x -= speed
}
if (Key.isDown (Key.UP)) {
this._y -= speed
} else if (Key.isDown (Key.DOWN)) {
this._y += speed;
}
}
That’s all the codes I’ve got in the whole Flash. I read a tutorial from Kirupa earlier so I followed the instructions to create this. I wonder if I missed something or I misinterpreted something. Is there anything wrong in the scripts up there? “object” did not turn red when it is moved over “obstacle1” or “obstacle2”. Why?