Skip to content

Commit

Permalink
adding actor documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Squeakrats committed Feb 26, 2016
1 parent 9bcd193 commit 81bdbf8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 27 deletions.
57 changes: 31 additions & 26 deletions docs/cruft/core/Actor.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#Actor
[engine/core/Actor.js](https://github.com/mjneil/CruftEngine/blob/master/engine/core/Actor.js)
#Actor extends [Emitter](Emitter.md)
[cruft/core/Actor.js](https://github.com/mjneil/CruftEngine/blob/master/cruft/core/Actor.js)
This class defines an Actor.

## Importing
```javascript
import Actor from "cruft/core/Actor"
```

## Constructors

### Actor( [ [guid](/primitives.md#number) ] )
Expand All @@ -10,7 +15,7 @@ This class defines an Actor.
```javascript
let actor = new Actor();
//or
let actor2 = new Actor(12);
let actor2 = new Actor(12); //actor2.guid === 12;
```


Expand All @@ -24,57 +29,57 @@ let actor2 = new Actor(12);
##Methods


### addComponent( )
DESC

### addComponent( [component](Component.md) )
Add a component to an actor.
```javascript
//example
actor.addComponent(component);
```


### removeComponent( )
DESC
### getComponent( [type](/primitives.md#string) )
Get a component of the specified type.

```javascript
//example
var transform = actor.getComponent("transform");
```


### getComponent( )
DESC
### removeComponent( [type](/primitives.md#string) )
Remove a component of the specified type.

```javascript
//example
actor.removeComponent("transform");
```

### addChild( )
DESC

### addChild( [child](Actor.md) )
Add a child to an actor.

```javascript
//example
actor1.addChild(actor2)
```

### removeChild( )
DESC
### removeChild( [child](Actor.md) )
Remove a child from an actor.

```javascript
//example
actor1.removeChild(actor2)
```


### setParent( )
DESC
### setParent( [parent](Actor.md) )
Method used to set actor's parent reference.
**AddChild already takes care of setting a child's parent. **

```javascript
//example
actor1.setParent(actor2).
```


### update( )
DESC
### update( [now](/primitives.md#number) , [deltaMs](/primitives.md#number) )
Recursive function to update all children Actor/Component 's of an actor.

```javascript
//example
actor.update(now, deltaMs)
```


Expand Down
10 changes: 9 additions & 1 deletion tests/Actor.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
import Actor from 'cruft/core/Actor.js';

describe("Actor", () => {

let actor = null;

beforeEach(() => {
actor = new Actor();
actor = null;
})

it('generates a random guid', () => {
actor = new Actor();
expect(actor.guid).toBeTruthy();
});

it('accepts a passed in guid', () => {
var id = 12;
actor = new Actor(id);
expect(actor.guid).toBe(id);
});



})

0 comments on commit 81bdbf8

Please sign in to comment.