Skip to content

Commit

Permalink
Updated example
Browse files Browse the repository at this point in the history
  • Loading branch information
akashgupta88 committed Jan 5, 2015
1 parent 5528c94 commit ffe864b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@

AGSpriteButton.xcodeproj/project.xcworkspace/xcuserdata/Partinder.xcuserdatad/UserInterfaceState.xcuserstate

AGSpriteButton.xcodeproj/project.xcworkspace/xcuserdata/xprees.xcuserdatad/UserInterfaceState.xcuserstate

*.xcscheme

AGSpriteButton.xcodeproj/xcuserdata/xprees.xcuserdatad/xcschemes/xcschememanagement.plist
7 changes: 5 additions & 2 deletions AGSpriteButton/MyScene.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ -(id)initWithSize:(CGSize)size {
button.position = CGPointMake(self.size.width / 2, self.size.height / 3);
[self addChild:button];

SKSpriteNode *someSprite = [SKSpriteNode spriteNodeWithColor:[UIColor greenColor] size:CGSizeMake(50, 50)];
someSprite.position = CGPointMake(self.size.width/2, 100);
[self addChild:someSprite];


//Perform target for event
[button addTarget:self selector:@selector(addSpaceshipAtPoint:) withObject:[NSValue valueWithCGPoint:CGPointMake(self.size.width / 2, self.size.height / 2)] forControlEvent:AGButtonControlEventTouchUpInside];

//Perform action on event
SKSpriteNode *someSprite = [SKSpriteNode spriteNodeWithColor:[UIColor greenColor] size:CGSizeMake(50, 50)];

SKAction *rotate = [SKAction rotateByAngle:M_PI_4 duration:0.5];
[button performAction:rotate onObject:someSprite withEvent:AGButtonControlEventTouchDown];

Expand Down
6 changes: 3 additions & 3 deletions AGSpriteButton/SwiftTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import Foundation

//Example on setting button in Swift.

var button:AGSpriteButton = AGSpriteButton(color:UIColor.redColor(), size:CGSize(width:100, height:50))
button.position = CGPoint(x:10, y:10)
//var button:AGSpriteButton = AGSpriteButton(color:UIColor.redColor(), size:CGSize(width:100, height:50))
//button.position = CGPoint(x:10, y:10)

self.addChild(button)
//self.addChild(button)


0 comments on commit ffe864b

Please sign in to comment.