Closed jamessimo closed 8 years ago
Use the addObj method to add a smaller rect to the large colored rect. The newer space shooter demo has an example - check out how the player names are created: https://github.com/sbiermanlytle/iioengine/blob/master/demos/scroll-shooter/SpaceShooter%2B.io.js
@sbiermanlytle that worked great, however I now want to do this to box2D objects.
This:
io.addToGroup('BLOCKS',world.CreateBody(bodyDef),0)
.CreateFixture(fixDef)
.GetShape()
.prepGraphics(this.io.b2Scale).setFillStyle('orange').addObj(new iio.SimpleRect(pxConv(20),pxConv(20)).addImage('img/star.png'));
Says that .addObj 'undefined is not a function' (without .addObj works)
Ok, I tried to implement that function at one point for box2d after a similar question on the forums and ran into an issue that made me start working on v1.3.
When you use box2d, none of the iio control structures are actually running - all it does is attach a draw function to the box2d objects and adds a call to a global draw functions after the physics update - so you'll need to create a new Box2d object and fix it to the parent one.
There will be a deeper integration with box2d in v1.3.
Is this still an open issue in version 1.4?
I think it is, the Box2d integration is basically the same in 1.4 as in 1.2. Still on the priority list though.
The new docs discuss this aspect of using iio object management vs Box2d object management: http://iio.js.org/#api/extras/box2d. Deeper mobile integration is more of a priority than deeper Box2d integration, so it may be a while until you can use iio's management functions on B2d objects
Hey guys, I want to draw a coloured iio rect with a small image in the center, however
.setFillStyle()
will always draw over the image.addImage()
is there a way around this? (if you set the alpha to 50% I can see the image in the center)Cheers!