-
Collision detection [Help]
what em i doing wrong it dose nothing
package game {
import flash.events.Event;
public class wallblock extends Walls {
public var hitbool:Boolean
public function wallblock() {
this.addEventListener(Event.ENTER_FRAME, maze)
function maze (e:Event) : void
{
if (character hitTestObject(this))
{
trace("Hit")
}
else{
trace("Miss")
}
}
}
}
}
-
Designer, Programmer, Musician
I don't know much about classess, but try something like this:
var mc:MovieClip = this;
public function wallblock(mc) {
this.addEventListener(Event.ENTER_FRAME, maze)
function maze (e:Event) : void
{
if (character.hitTestObject(mc))
{
trace("Hit")
}
else{
trace("Miss")
}
}
}
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
-
Designer, Programmer, Musician
Post your .fla and you .as file
Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries
-
how do i do that i am new ti this forum
thats the whole
wall block class
and here is my main class
package game
{
import flash.display.MovieClip;
import flash.ui.Keyboard;
import flash.events.Event;
import flash.events.KeyboardEvent;
public class Walls extends MovieClip
{
public var bckg:blok;
var bcount:int = -1;
var by:int = 0;
public var character:char;
public var player:MovieClip;
public var zid:wallblock
public function Walls()
{
trace("hi");
// Background //
for (var q:int = 0; q < 150; q++)
{
bcount += 1;
if (bcount == 15)
{
bcount = 0;
by += 40;
}
bckg = new blok();
bckg.x = bcount * 40;
bckg.y = by;
addChild(bckg);
}
// Character //
character = new char ;
character.x = 20;
character.y = 60;
player = character
addChild(character);
// wall //
zid= new wallblock
zid.x = 80
zid.y = 80
trace(zid.hitbool)
addChild(zid)
while (zid.hitbool)
{
trace("hit")
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|