im learning cocos2d [open gl wrapper for objective C on iPhone], and now playing with sprites have found this in a example,
enum {
easySprite = 0x0000000a,
mediumSprite = 0x0000000b,
hardSprite = 0x0000000c,
backButton = 0x0000000d,
magneticSprite = 0x0000000e,
magneticSprite2 = 0x0000000f
};
…
-(id) init
{...
/second sprite
TSprite *med = [TSprite spriteWithFile:@"butonB.png"]; //blue
[med SetCanTrack:YES];
[self addChild: med z:1 tag:mediumSprite];
med.position=ccp(299,230);
[TSprite track:med];
so the variable defined in the enum is used in the tag name of the created sprite object,
but i don understand
- why give values in hexa to the tags to use
- the enum with out tags
as I knew this enum in obj C and C
typedef enum {
JPG,
PNG,
GIF,
PVR
} kImageType;
thanks!
Enums are automatically assigned values, incremented from 0 but you can assign your own values.
If you don’t specify any values they will be starting from 0 as in:
But you could assign them values:
or even
anything you want, repeating values are ok as well.
I’m not sure why they are given those specific values but they might have some meaning related to use.