Class: SKNode

Inherits:
Object show all
Defined in:
lib/cocoa/sugarcube-spritekit/sknode.rb

Instance Method Summary collapse

Instance Method Details

#<<(node) ⇒ Object



3
4
5
# File 'lib/cocoa/sugarcube-spritekit/sknode.rb', line 3

def <<(node)
  addChild(node)
end

#[](key) ⇒ Object



11
12
13
14
# File 'lib/cocoa/sugarcube-spritekit/sknode.rb', line 11

def [](key)
  self.userData ||= {}
  userData[key.to_s]
end

#[]=(key, value) ⇒ Object



16
17
18
19
# File 'lib/cocoa/sugarcube-spritekit/sknode.rb', line 16

def []=(key, value)
  self.userData ||= {}
  userData[key.to_s] = value
end

#each_named(name, &block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/cocoa/sugarcube-spritekit/sknode.rb', line 21

def each_named(name, &block)
  if block.arity == 1
    using_block = -> (node, stop_ptr) { block.call(node) }
  else
    using_block = block
  end
  enumerateChildNodesWithName(name, usingBlock: using_block)
end

#run_action(action, &completion) ⇒ Object



7
8
9
# File 'lib/cocoa/sugarcube-spritekit/sknode.rb', line 7

def run_action(action, &completion)
  runAction(action, completion: completion)
end

#to_sObject



30
31
32
# File 'lib/cocoa/sugarcube-spritekit/sknode.rb', line 30

def to_s
  "#<#{self.class}:0x#{self.object_id.to_s(16)} position=#{position.inspect} name=#{name.inspect}>"
end