sbiermanlytle / iioEngine

iio Engine: A JavaScript game engine for HTML5 Canvas
http://iioengine.com
456 stars 81 forks source link

Attaching a label on an object #33

Closed loicknuchel closed 9 years ago

loicknuchel commented 9 years ago

Hi,

Thank you for your library, I'm building a little game with iio Engine (similar to shooter app) and I wanted to add labels on some objects (like meteors) but I didn't found how to... Is it possible ?

An other thing, do you support touch for mobile screens ? If not, do you known a way to do it ?

Thanks a lot

sbiermanlytle commented 9 years ago

Yes, labels are possible. Check out this demo for 1.2: https://github.com/sbiermanlytle/iioengine/blob/master/archives/1.2/demos/scroll-shooter/SpaceShooter%2B.io.js

labels are added to the player objects like this:

io.addToGroup('players', new iio.SimpleRect(x,y)
   .createWithAnim(playerSprites.getSprite(0,0,99,75),'level'))
   .addAnim(playerSprites.getSprite(0,76,99,77),'left')
   .addAnim(playerSprites.getSprite(0,153,99,76),'right')
   .addObj(new iio.Text(name)
       .setFont('20px Consolas')
       .setTextAlign('center')
       .setFillStyle('white')
       ,false,io.context,0,60);
       //boolean controls draw order

In iio 1.3, you can use the add function on any object to add any other object.

You can use standard JavaScript functions to detect touch: https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Touch_events#Setting_up_the_event_handlers

Hope this helps!

loicknuchel commented 9 years ago

Thanks a lot !