ios - SKShapeNode select X amount -


question

i'm developing poker software ~ purely fun.

now when comes chips, i'm having nightmare. 1 positioning them, 2 denominations , three selecting ones i'll need! seems impossible current design.

basically, draw skshapenode give name of denomination , player name. however, chip can drawn 50 times same name.

when come animating these chips, can see wall of impossibility..

once i've made function choose right denominations of chips use call or raise etc, how begin write pseudo code?

i require 2 large chips, 1 small chip , 2 medium chips {     sknode *node = [self childnodewithname:denomination, playername];      runaction.. } 

baring in mind, i'll need take 2 of 20 there in chip stack.. change ownership of chip..

is possible? or overcomplicating issue..?

you need rework solution little bit. this:

first, subclass skspritenode (or sk whatever node like) make chip:

chip.h

@interface chip : skspritenode  @property (nonatomic, retain) nsstring *player; @property int denomination;  @end 

chip.m

@implementation chip - (id)initwithcolor:(uicolor *)color size:(cgsize)size {   if(self = [super initwithcolor:color size:size])   {     self.name = @"chip";   }    return self; }  @end 

now you've got can reasonably enumerate , inspect.

add bunch of chips game scene:

gamescene.m

-(void)didmovetoview:(skview *)view {   for(int = 0; < 50; i++)   {     chip *chip = [[chip alloc] initwithcolor:[skcolor greencolor]                                         size:cgsizemake(100.0, 100.0)];      chip.player = @"some player";     chip.denomination = 10;      [self addchild:chip];   } } 

then when it's time pop off number of chips:

 -(void)popchipsfromplayer:(nsstring *)playername            ofdenomination:(int)denomination             numberofchips:(int)numchips {   __block int i;    [self enumeratechildnodeswithname:@"chip"                          usingblock:^(sknode *node, bool *stop) {                            chip *chip = (chip *)node;                            if(chip.denomination == denomination &&                               [playername isequaltostring:chip.player])                            {                              if(i==numchips)                                return;                               skaction *moveup = [skaction movebyx:0.0                                                                 y:200.0                                                          duration:3];                               [chip runaction:moveup];                               i++;                            }                          }]; } 

call method:

  [self popchipsfromplayer:@"some player"             ofdenomination:10              numberofchips:3]; 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -