428 |
429 |
430 |
438 |
439 |
440 | Pack a single bin into the sprite.
441 | Each bin will have a unique identitifer.
442 | If no identifier is supplied in the id
parameter, one will be created.
443 | Note: The supplied id
is used as an object index, so numeric values are fastest!
444 | Bins are automatically refcounted (i.e. a newly packed Bin will have a refcount of 1).
445 | When a bin is no longer needed, use the ShelfPack.unref
function to mark it
446 | as unused. When a Bin's refcount decrements to 0, the Bin will be marked
447 | as free and its space may be reused by the packing code.
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 | Parameters
465 |
466 |
467 |
468 |
469 |
w (number)
470 | Width of the bin to allocate
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
h (number)
479 | Height of the bin to allocate
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
id ((number | string)?)
488 | Unique identifier for this bin, (if unsupplied, assume it's a new bin and create an id)
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 | Returns
502 | Bin
:
503 | Bin object with
504 | id
505 | ,
506 | x
507 | ,
508 | y
509 | ,
510 | w
511 | ,
512 | h
513 | properties, or
514 | null
515 | if allocation failed
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 | Example
525 |
526 |
527 | var results = sprite.packOne(12, 16, 'a');
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |