piqnt / stage.js

2D HTML5 rendering and layout engine for game development
http://piqnt.com/stage.js/
Other
2.43k stars 241 forks source link

How can I fill only a ship in asteroids game? #35

Closed edstarck closed 7 years ago

edstarck commented 7 years ago

Hello! Can you help me, please. I can't fill path shape ship for exemple color #e1181e, without others world. I tried: shipBody.shapes[0].proto = ui.p2; shipBody.shapes[0].proto.options.lineColor = '#e1181e'; But it paints all world to #e1181e. I need color ship to #e1181e and asteroids #808080. How i can do it? What am I doing wrong? Thank you. Best regards

shakiba commented 7 years ago

I updated p2 renderer to accept options per object/shape, for example:

shipBody.render = { fillColor : '#e1181e' };

In your code ui.p2.options.lineColor = color changes default options, it wont do anything additional if you assign it to "proto". For changing default options I recommend passing them as second argument to Stage.P2.

You are welcome!

edstarck commented 7 years ago

Hello! Thank you for your reply. I update p2.js and stage-p2.js. Paste shipBody.render = { fillColor : '#e1181e' }; in my code to app.js. But nothing has changed. For example: http://evgber.16mb.com/asteroids/ What am I doing wrong, I don't undestand. Best regards.

shakiba commented 7 years ago

Ops, sorry! It seems that last time I did not push my changes successfully. Just pushed them again, please update your files again.

By the way, you could use stage.background("#444") to set background color.

edstarck commented 7 years ago

it's great! Thank you very much for your help! All it's work.