# CCEffectRefraction Class Reference

Inherits from | CCEffect : NSObject
Declared in | CCEffectRefraction.h

## Overview

CCEffectRefraction uses refraction to simulate the appearance of a transparent object contained within an environment. Refraction is controlled with a single refraction strength value, the normal map, and a refraction environment sprite.

## Tasks

### Accessing Effect Attributes

- `refraction` property
- `environment` property
- `normalMap` property

### Initializing a CCEffectRefraction object

- `– init`
- `– initWithRefraction:environment:`
- `– initWithRefraction:environment:normalMap:`
- `+ effectWithRefraction:environment:`
- `+ effectWithRefraction:environment:normalMap:`

## Properties

### environment

The environment that will be refracted by the affected node. Typically this is a sprite that serves as the background for the affected node so it appears that the viewer is seeing the refracted environment through the refracting node.

`@property (nonatomic, strong) CCSprite *environment`

#### Declared In

`CCEffectRefraction.h`

### normalMap

The normal map that encodes the normal vectors of the affected node. Each pixel in the normal map is a 3 component vector that is perpendicular to the surface of the sprite at that point.

`@property (nonatomic, strong) CCSpriteFrame *normalMap`

#### Declared In

`CCEffectRefraction.h`

### refraction

The refraction strength value. This value is in the range [-1..1] with -1 resulting in maximum minification of the refracted image, 0 resulting in no refraction, and 1 resulting in maximum magnification of the refracted image.

`@property (nonatomic) float refraction`

#### Declared In

`CCEffectRefraction.h`

## Class Methods

### effectWithRefraction:environment:

Creates a CCEffectRefraction object with the supplied parameters and a nil normal map.

`+ (id)effectWithRefraction:(float)refraction environment:(CCSprite *)environment`

#### Parameters

refraction

  The refraction strength.

environment

  The environment image that will be refracted by the affected node.

#### Return Value

The CCEffectRefraction object.

#### Declared In

`CCEffectRefraction.h`

### effectWithRefraction:environment:normalMap:

Creates a CCEffectRefraction object with the supplied parameters.

`+ (id)effectWithRefraction:(float)refraction environment:(CCSprite *)environment normalMap:(CCSpriteFrame *)normalMap`

#### Parameters

refraction

  The refraction strength.

environment

  The environment image that will be refracted by the affected node.

normalMap

  The normal map of the affected node. This can also be specified as a property of the affected sprite.

#### Return Value

The CCEffectRefraction object.

#### Declared In

`CCEffectRefraction.h`

## Instance Methods

### init

Initializes a CCEffectRefraction object with the following default parameters: refraction = 1.0, environment = nil, normalMap = nil

`- (id)init`

#### Return Value

The CCEffectRefraction object.

#### Declared In

`CCEffectRefraction.h`

### initWithRefraction:environment:

Initializes a CCEffectRefraction object with the supplied parameters and a nil normal map.

`- (id)initWithRefraction:(float)refraction environment:(CCSprite *)environment`

#### Parameters

refraction

  The refraction strength.

environment

  The environment image that will be refracted by the affected node.

#### Return Value

The CCEffectRefraction object.

#### Declared In

`CCEffectRefraction.h`

### initWithRefraction:environment:normalMap:

Initializes a CCEffectRefraction object with the supplied parameters.

`- (id)initWithRefraction:(float)refraction environment:(CCSprite *)environment normalMap:(CCSpriteFrame *)normalMap`

#### Parameters

refraction

  The refraction strength.

environment

  The environment image that will be refracted by the affected node.

normalMap

  The normal map of the affected node. This can also be specified as a property of the affected sprite.

#### Return Value

The CCEffectRefraction object.

#### Declared In

`CCEffectRefraction.h`