Thursday, March 31, 2016

CJAW: Swift Blocks progressive blog post

Added few more classes from
https://www.bloc.io/tutorials/swiftris-build-your-first-ios-game-with-swift#!/chapters/681

in here : https://github.com/swtsvn/CJAW/blob/GameMaker/NW/Blocks.zip

This one is about protocols, adhering to them, creating basic skeleton for color of block and actual block class.

Monday, March 21, 2016

CJAW: Swift Blocks few more lines of code

Added few more lines of code to Swift Blocks project, which is inspiration from
https://www.bloc.io/tutorials/swiftris-build-your-first-ios-game-with-swift#!

Code here: https://github.com/swtsvn/CJAW/blob/GameMaker/NW/Blocks.zip

Apologies for the slow pace.



Saturday, March 12, 2016

CJAW: Game Maker Intro

Code snippet for this week:

Not exactly code, but dipping my toes into Game Maker

First Draft project in Game Maker here: https://github.com/swtsvn/CJAW/tree/GameMaker/GameMaker

Simple one following their tutorial.

Thursday, March 3, 2016

CJAW: Swift Maps

Added basic map with latitude and longitude set to point to London.
Added two balloon points (Annotations to be called specifically). On right on London, and another just a bit north.
Added an overlay circle of 50 km with a green stroke color. The overlay is transparent.

These are basics of Maps that can be referred from any online resource. Hence not adding much of description in this blog to save repetition.

Code here:
https://github.com/swtsvn/CJAW/blob/Networking/NW/Mapz.zip

P.S


http://www.latlong.net - This is a site that gives you latitude and longitude value if you type the place name.

Sunday, February 28, 2016

CJAW: Swift - Device's motion capture

Apologies for the long gap between my last post and this one.

Here is the source code of my play with Core Motion on iPad
It simply moves a SKSpriteNode based on how the iPad is tilted. Always moving towards the end that is facing down, as per the user's movement of the iPad.

https://github.com/swtsvn/CJAW/tree/Networking/NW/Vib1

Make Sure. .  the orientation setup is setup so that only "Portrait" or any one of the options is chosen, so that the sprite node moves as expected with the application screen fixed to a certain orientation.

Kindly consider this as Part1. I am planning to play more with Motion. See you soon.


Saturday, May 2, 2015

CJAW : Swift TicTacToe Part2

This week, added some minor changes to the Tic Tac Toe Game.  Basically replaced all x,y parameters to CGPoint, and used grid size’s half width and half height in order to position the Xs and Os. Then added a reset button to clear the nodes on screen. 

To add reset button : 
In Main.Storyboard, drag and drop a button(from Object library. If you are not able to see Object library on the right bottom corner, then do View->Utilities->Show Identity Inspector to see the library) into a suitable location inside the view controller. I moved the button to bottom left corner, below a space where the grid would appear. 

If you are not able to view assistant editor, then click on View->Assistant Editor->Show Assistant Editor. This window shows the GameViewController.swift file’s code. Do a control+drag from the button to somewhere inside the class GameViewController. When prompted, chose Connection:Action ( to call a function when the button is touched), Name: OnTouch(), Type:UIButton, Event:Touch Up Inside, Arguments: Sender. This will create a function inside the  GameViewController class. This function will be called when the button is touched.

     

@IBAction func OnTouch(sender: UIButton) {
        PresentGameScene()
    }

Create a function called PresentGameScene() which would delete all existing nodes inside the GameScene, and make the view present the scene once again, fresh.

func PresentGameScene(){
        if let scene = GameScene.unarchiveFromFile("GameScene") as? GameScene {
            // Configure the view.
            let skView = self.view as SKView
            skView.showsFPS = true
            skView.showsNodeCount = true
            
            /* Sprite Kit applies additional optimizations to improve rendering performance */
            skView.ignoresSiblingOrder = true
            
            /* Set the scale mode to scale to fit the window */
            scene.scaleMode = .AspectFill
            
            scene.Reset();
            skView.presentScene(scene)
       }

   //Make sure to reuse the code in 

     override func viewDidLoad() {
        super.viewDidLoad()
        PresentGameScene();
 }

Now we need to implement scene.Reset(). In GameScene.swift file, implement the function

  func Reset(){
        self.removeAllChildren();
    }

That is all. It is quite simple. removeAllChildren takes care of removing all the child nodes from the game scene, and cleans the slate for fresh start.

Github link: https://github.com/swtsvn/CJAW/tree/TicTacMain/TicTac