//
//  SpeechBubble.swift
//  sleazyburger
//
//  Created by Aslak Gronflaten on 1/25/15.
//  Copyright (c) 2015 Javelin. All rights reserved.
//

import SpriteKit

class SpeechBubble : SKSpriteNode {
    let words = SKLabelNode(fontNamed: "Marker Felt Wide")
    let delay = 1.1
    
    convenience init(dummy : Bool) {
        self.init(imageNamed: "request_giveme_600")
        self.position = CGPointMake(847, 768-116)
//        parent.addChild(self)
        self.hidden = true
        
        words.fontSize = 32
        words.fontColor = SKColor.blackColor()
        self.addChild(words)
        words.zPosition = 101
        //        words.position = CGPointMake(CGRectGetMidX(frame), CGRectGetMidY(frame))
    }
    
    func speak(text : String) {
        words.text = text
        self.hidden = false
        self.runAction(SKAction.fadeAlphaTo(1.0, duration: 0.1))
        self.runAction(SKAction.waitForDuration(delay)) {
            self.runAction(SKAction.fadeAlphaTo(0.0, duration: 0.3))
        }
    }
}
