Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Inside my PlayerBehavior class I have:

class PlayerBehavior extends Sup.Behavior {
  public playerCol = this.actor.arcadeBody2D;
  speed = 0.3;
  jumpSpeed = 0.45;
  public health = 100;


From inside EnemyBehavior, I want to check colission with just the player and lower his health.

For this I have:

 if(Sup.ArcadePhysics2D.collides(this.actor.arcadeBody2D, Sup.getActor("Player").getBehavior(PlayerBehavior).playerCol))
       {
        Sup.getActor("Player").getBehavior(PlayerBehavior).LowerHealth(1);
       }


However, the screen goes dark when I try this. What am I doing wrong?

Kind regards.

While I'm not quite sure why the screen is going dark, I can offer a different way to go about this.


In your EnemyBehavior, change the collision check to:

if(Sup.ArcadePhysics2D.collides(this.actor.arcadeBody2D, Sup.getActor("Player").arcadeBody2D)
{
        Sup.getActor("Player").getBehavior(PlayerBehavior).LowerHealth(1);
}

You can then remove

public playerCol = this.actor.arcadeBody2D;

from your PlayerBehavior.


In the future, you can usually just call whatever component you need [ arcadeBody, camera, spriteRenderer, etc. ] directly with:

Sup.getActor('Name Of Actor').NameOfComponent


Hope this helps!

(+1)

Thank you once again Spencer. With your help, I was able to finish my quick test with Superpowers. Awesome!
However, I exported the project, and opening the index.html shows a "Could not load plugin list" error. A quick google search showed that it should run if uploaded to a server, so I did. Unfortunately I get the same results.  This is the link.

Any reason why that could be happening? Thanks in advance, you've been of great help and I really appreciate you taking the time to reply to my questions :)

Hmm, I don't know about that one...

Have you tried uploading it here on itch? I've never used the Azure service before so I'm not sure if it's just an issue on their end or not.