2 Replies - 260 Views - Last Post: 22 April 2013 - 06:35 PM Rate Topic: -----

#1 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 158
  • Joined: 15-February 11

CCMenuItemSprites

Posted 22 April 2013 - 04:26 PM

I'm having some strange results. I have created a CCMenu with 4 CCMenuItemSprites. One of the CCMenuItemSprites is simply a background but I use it instead of a simple CCSprite because it blocks the user from being able to click game items behind the menu. What's strange is that if I place my CCMenuItemSprites on top of the "background" button they do not call theyre selector when clicked but when I put them behind the "background" button they work... what's going on?

-(void)createDice
{   
    self.dmPosition = ccp(500,500);
    
    CCSprite *diceMenuBackgroundSprite = [CCSprite spriteWithFile:@"DiceMenuBackground.png"];
    CCMenuItemSprite *dmBackgroundMenuItem = [CCMenuItemSprite itemWithNormalSprite:diceMenuBackgroundSprite selectedSprite:nil];
    dmBackgroundMenuItem.position = self.dmPosition;
    
    CCSprite *rollDiceSprite = [CCSprite spriteWithFile:@"rollDiceButton.png"];
    CCMenuItemSprite *rollDiceMenuItem = [CCMenuItemSprite itemWithNormalSprite:rollDiceSprite selectedSprite:nil target:self selector:@selector(rolled:)];
    rollDiceMenuItem.position = ccp(self.dmPosition.x,self.dmPosition.y-100);
    
    self.redDiceA = [CCSprite spriteWithFile:@"redDice.png"];
    self.redDiceB = [CCSprite spriteWithFile:@"redDice.png"];
    self.redDiceC = [CCSprite spriteWithFile:@"redDice.png"];
    self.whiteDiceA = [CCSprite spriteWithFile:@"whiteDice.png"];
    self.whiteDiceB = [CCSprite spriteWithFile:@"whiteDice.png"];
    
    self.redDiceAS = [CCSprite spriteWithFile:@"redDiceSelected.png"];
    self.redDiceBS = [CCSprite spriteWithFile:@"redDiceSelected.png"];
    self.redDiceCS = [CCSprite spriteWithFile:@"redDiceSelected.png"];
    self.whiteDiceAS = [CCSprite spriteWithFile:@"whiteDiceSelected.png"];
    self.whiteDiceBS = [CCSprite spriteWithFile:@"whiteDiceSelected.png"];
    
    self.dice1 = [DiceButton itemWithNormalSprite:self.redDiceA selectedSprite:nil target:self selector:@selector(diceSelected:)];
    self.dice1.position = ccp(self.dmPosition.x-90, self.dmPosition.y+90);
    self.dice1.index = 1;
    
    self.dice2 = [DiceButton itemWithNormalSprite:self.redDiceB selectedSprite:nil target:self selector:@selector(diceSelected:)];
    self.dice2.position = ccp(self.dmPosition.x, self.dmPosition.y+90);
    self.dice2.index = 2;
    
    self.dice3 = [DiceButton itemWithNormalSprite:self.redDiceC selectedSprite:nil target:self selector:@selector(diceSelected:)];
    self.dice3.position = ccp(self.dmPosition.x+90, self.dmPosition.y+90);
    self.dice3.index = 3;
    
    
    self.dice4 = [DiceButton itemWithNormalSprite:self.whiteDiceA selectedSprite:nil target:self selector:@selector(diceSelected:)];
    self.dice4.position = ccp(self.dmPosition.x-45, self.dmPosition.y-5);
    self.dice4.index = 4;
    
    self.dice5 = [DiceButton itemWithNormalSprite:self.whiteDiceB selectedSprite:nil target:self selector:@selector(diceSelected:)];
    self.dice5.position = ccp(self.dmPosition.x+45, self.dmPosition.y-5);
    self.dice5.index = 5;
    
    self.diceMenu = [CCMenu menuWithItems: nil];
    
    self.diceMenu.position = CGPointZero;
    
    
    [self.diceMenu addChild:dmBackgroundMenuItem];
    [self.diceMenu addChild:rollDiceMenuItem];
    [self.diceMenu addChild:self.dice1];
    [self.diceMenu addChild:self.dice2];
    [self.diceMenu addChild:self.dice3];
    
    [self.diceMenu addChild:self.dice4];
    [self.diceMenu addChild:self.dice5];
    
    [self addChild:self.diceMenu];
    
}



If I put the dmBackgroundMenuItem on the pottom of the list the buttons work but the are blured by the opacity of the background...

Is This A Good Question/Topic? 0
  • +

Replies To: CCMenuItemSprites

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: CCMenuItemSprites

Posted 22 April 2013 - 06:18 PM

Are you getting any build warnings?
Was This Post Helpful? 0
  • +
  • -

#3 lifeinbinary  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 158
  • Joined: 15-February 11

Re: CCMenuItemSprites

Posted 22 April 2013 - 06:35 PM

No build warnings... I tried playing with the z: values but with the same result: items only get selected in the back (lowest z value)... I'm thinking to just make my own menu/button classes and using the onTouchesEnded to deal with them... unless someone can help me straighten this out :(
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1