Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

behavior listener events not launched if setVisible false #126

Open
@rehanog

Description

@rehanog

Not sure if this issue represents a feature or a bug, i.e., not sure if you intended to switch off listeners for invisible objects. To me, it makes sense if behavior listeners are active, even if an actor is not visible.

The goal of the sample code below is for the actor to become visible and perform relevant behaviour once the mouse is clicked.

Code that works:

Using this code, "something happens" is output on the console log when I click the button

this.oMyActor.setVisible( false );

this.oMyBehavior.addListener( {
   behaviorStarted : function( behavior, time, actor ) {
      console.log( "Something happened" );
   }
} );

this.oMyButton.mouseClick.mouseClick = function( mouseEvent ) {
   that.oMyActor.setVisible( true );
   that.oMyBehavior.setFrameTime( that.scene.time, 2000 );
};

this.oMyActor.addBehavior( oMyBehavior );

Code I would prefer:

Using this code, nothing happens when I click the button

this.oMyActor.setVisible( false );

this.oMyBehavior.addListener( {
   behaviorStarted : function( behavior, time, actor ) {
      actor.setVisible( true );
      console.log( "Something happened" );
   }
} );

this.oMyButton.mouseClick = function( mouseEvent ) {
   that.oMyBehavior.setFrameTime( that.scene.time, 2000 );
};

this.oMyActor.addBehavior( oMyBehavior );

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions