Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actor does not set initial opacity based on Color alpha channel in its constructor #307

Closed
MrAlexLau opened this issue May 9, 2014 · 4 comments
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Milestone

Comments

@MrAlexLau
Copy link

Using version 0.2.5 (I haven't tried in other version), I have an actor declared like this:
var ground = new ex.Actor(0, Config.gameHeight - Config.groundHeight, Config.gameWidth, 5, ex.Color.Transparent);

Which results in a white bar:
image

I would expect not to see the bar at all.

@kamranayub
Copy link
Member

We can look into this, definitely seems wrong.

In the meantime, you can also set ground.invisible = true to not draw it.

Also, if you want to take some action when your jumper hits the ground, it might be worth using a Trigger instead as it's light-weight and meant for, well, triggering things when actors touch its bounds.

@kamranayub kamranayub added bug and removed question labels May 9, 2014
@kamranayub
Copy link
Member

Yah, I think I found it.

There's a line in Actor.draw that says:

if(this.color) this.color.a = this.opacity;

Well, in the constructor, we're not setting the initial opacity to the color you passed in (if any). So it's always 1.

To workaround, you can either set invisible or opacity.

@kamranayub kamranayub changed the title Color.Transparent rendering as white Actor does not set initial opacity based on Color alpha channel in its constructor May 9, 2014
@jedeen jedeen added this to the 0.3 Release milestone May 9, 2014
@MrAlexLau
Copy link
Author

Setting the opacity to zero works perfectly. Thanks for the suggestion.

@eonarheim
Copy link
Member

Good catch. I feel like the actor opacity should default to the alpha of the color passed in at constructor time. I will make the change.

@jedeen jedeen modified the milestones: 0.3 Release, 0.4 Release Nov 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue describes undesirable, incorrect, or unexpected behavior
Projects
None yet
Development

No branches or pull requests

4 participants