Sha256: 985718671d5fd9a69dc0fe0b682f1c8a9b3d200a4fe8b2162b9fb40557a8c27d

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 Bytes

Contents

module Joybox
  module Core

    class Sprite < CCSprite

      alias_method :stop_all_actions, :stopAllActions
      alias_method :run_action, :runAction

      def self.new(options = {})

        sprite ||= new_with_file(options) if options.has_key? (:file_name)
        sprite ||= new_with_texture(options) if options.has_key? (:texture)

        sprite.position = options[:position] if options.has_key? (:position)

        sprite
      end


      private 

      def self.new_with_file(options = {})

        spriteWithFile(options[:file_name])
      end


      def self.new_with_texture(options = {})

        if options.has_key? (:rect)

          spriteWithTexture(options[:texture], rect: options[:rect])
        else

          spriteWithTexture(options:[:texture])
        end

      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
joybox-0.0.3 lib/joybox/cocos2d/core/sprite.rb