12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- cc.Class({
- extends: cc.Component,
- properties: {
- atlasCards:
- {
- default:null,
- type:cc.SpriteAtlas
- },
- m_nCardId:0,
- },
- setId:function(id) {
- this.m_nCardId = id;
- if (this.atlasCards) {
- var color = this.cardColor() + 1;
- var num = this.cardNum();
- var sprName = "handmah_" + color + num;
- if (this.m_nCardId == 0) {
- sprName = "handmah_" + 0 + 0;
- }
- var frame = this.atlasCards.getSpriteFrame(sprName);
- if (frame == null) {
- }
- this.node.getComponent(cc.Sprite).spriteFrame = frame;
- }
- },
- cardId:function () {
- return this.m_nCardId;
- },
- cardColor:function () {
- return ((this.m_nCardId>>4) & 0x0F);
- },
- cardNum:function () {
- return (this.m_nCardId & 0x0F);
- },
- getCardColor:function (CardId) {
- return ((CardId>>4) & 0x0F);
- },
- getCardNum:function (CardId) {
- return (CardId & 0x0F);
- },
- });
|