A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Collision detection [Help]

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    22

    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")

    }
    }

    }

    }

    }

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    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

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    22
    that wont work :/

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Post your .fla and you .as file
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    22
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center