Hi,
i am new to sparrow, but it is just a great project! thanks for that ...
now, i am going to build my first (simple) game ..
BUT i am running into a problem:
I have a SPStage subclass which is added as child to the main stage (Class: Game). Here is the Code:
@implementation PlayStage01 - (id)init { if ((self = [super init])) { SPTextField *title = [SPTextField textFieldWithWidth:320 height:70 text:@"Play ..... Stage 01" fontName:@"Helvetica" fontSize:70 color:0xFFFFFF]; [self addChild:title]; // Play Button SPTexture *buttonTexture = [SPTexture textureWithContentsOfFile:@"button_big.png"]; SPButton *playButton = [SPButton buttonWithUpState:buttonTexture text:@"Play"]; [playButton addEventListener:@selector(playButtonTriggered:) atObject:self forType:SP_EVENT_TYPE_TRIGGERED]; playButton.x = (320-playButton.width)/2; playButton.y = title.height + 20; [self addChild:playButton]; [self startTween]; } return self; } - (void)playButtonTriggered:(SPEvent *)event { /* Menu *menuScene = [[Menu alloc] init]; [(Game *)self.stage showScene:menuScene]; */ [self startTween]; } -(void)startTween{ SPImage *img = [SPImage imageWithContentsOfFile:@"texture_test.png"]; [self addChild:img]; SPTween *tween = [SPTween tweenWithTarget:img time:4.0]; [tween animateProperty:@"y" targetValue:100.0f]; [self.stage.juggler addObject:tween]; }
The Tween starts only after releasing the "playButtonTriggered" event calls "startTween"! The tween wont start, when the init function is calling start tween!
Why does this happen!? What am I doing wrong!?
Thank you for help in advance!
chris