Skip to content

Commit

Permalink
adding Actor, Component, and ActorFactory docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Squeakrats committed Feb 27, 2016
1 parent 26ee533 commit e5b0847
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 7 deletions.
18 changes: 11 additions & 7 deletions docs/cruft/core/Actor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This class defines an Actor.

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

## Constructors
Expand All @@ -21,10 +21,11 @@ let actor2 = new Actor(12); //actor2.guid === 12;


## Properties
.[guid](/primitives.md#number) - guid of the actor.
.[parent](Actor.md) - Strong reference to parent actor.
.[components](/primitives.md#object) - Object containing strong references to the actor's components.
.[children](/primitives.md#object) - Object containing strong references to the actor's children.

.[children](/primitives.md#object) - Object containing strong references to the actor's children.
.[initialized](/primitives.md#boolean) - Whether the actor has been initialized.

##Methods

Expand All @@ -39,7 +40,7 @@ actor.addComponent(component);
Get a component of the specified type.

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


Expand All @@ -55,7 +56,10 @@ actor.removeComponent("transform");
Add a child to an actor.

```javascript
actor1.addChild(actor2)
let actor1 = new Actor();
let actor2 = new Actor();

actor1.addChild(actor2);
```

### removeChild( [child](Actor.md) )
Expand All @@ -71,15 +75,15 @@ Method used to set actor's parent reference.
**AddChild already takes care of setting a child's parent. **

```javascript
actor1.setParent(actor2).
actor1.setParent(actor2);
```


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

```javascript
actor.update(now, deltaMs)
actor.update(now, deltaMs);
```


Expand Down
42 changes: 42 additions & 0 deletions docs/cruft/core/ActorFactory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[cruft/core/ActorFactory.js](https://github.com/mjneil/CruftEngine/blob/master/cruft/core/ActorFactory.js)
This class defines an ActorFactory.

## Importing
```javascript
import ActorFactory from "cruft/core/ActorFactory";
```

## Constructors

### ActorFactory( )

```javascript
let factory = new ActorFactory();
```


##Methods

### register( [name](/primitives.md#string), [creator](/primitives.md#function) )
[name](/primitives.md#string) - name to associate with the given creator function.
[creator](/primitives.md#function) - a function that returns an actor.

```javascript
let EmptyCreator = () => {
return new Actor();
}
factory.register("Empty", EmptyCreator)
```

### create( [name](/primitives.md#string), [config](/primitives.md#object) )
creates an actor of the given type.
```javascript

let MyCreator = (config) => {
return new Actor(config.guid);
}

factory.register("MyCreator", MyCreator)
let actor = factory.create("MyCreator", {guid : 12});
```

48 changes: 48 additions & 0 deletions docs/cruft/core/Component.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#Component extends [Emitter](Emitter.md)
[cruft/core/Component.js](https://github.com/mjneil/CruftEngine/blob/master/cruft/core/Component.js)
This class defines a Component.

## Importing
```javascript
import Component from "cruft/core/Component";
```

## Constructors

### Component( [ [guid](/primitives.md#number) ] )
[guid](/primitives.md#number) - guid of the component.

```javascript
let component = new Component();
```



## Properties
.[guid](/primitives.md#number) - guid of the component.
.[actor](Actor.md) - Strong reference to the parent Actor.


##Methods


### initialize( )
Initializes the component.
**initialize is already called once the component has been added to an active actor in the scene. **
```javascript
component.initialize();
```

### update( [now](/primitives.md#number), [deltaMs](/primitives.md#number) )
Update the component every game loop.
```javascript
component.update(now, deltaMs);
```


### destroy( )
//DESC

```javascript
//EXAMPLE
```
Empty file added docs/cruft/core/Emitter.md
Empty file.
32 changes: 32 additions & 0 deletions docs/cruft/core/Scheduler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

[cruft/core/Scheduler.js](https://github.com/mjneil/CruftEngine/blob/master/cruft/core/Scheduler.js)
This class defines a Scheduler.

## Importing
```javascript
import Scheduler from "cruft/core/Scheduler";
```

## Constructors

### Scheduler( )

```javascript
let scheduler = new Scheduler();
```


##Methods

### start( [deltaMs](/primitives.md#number) )
Starts the scheduler with the given delay.
```javascript
scheduler.start(17);
```

### kill( )
Stops the scheduler from updating.
```javascript
scheduler.kill()
```

9 changes: 9 additions & 0 deletions docs/primitives.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ let a = {
Engine :false
}
```

### Function
```javascript
let add = (a, b) => {
return a + b;
}
let c = add(6, 6);
```

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pages:
- Component : 'cruft/core/Component.md'
- ActorFactory : 'cruft/core/ActorFactory.md'
- Scheduler : 'cruft/core/Scheduler.md'
- Emitter : 'cruft/core/Emitter.md'
- Math :
- vec2 : 'cruft/math/vec2.md'
- vec3 : 'cruft/math/vec3.md'
Expand Down

0 comments on commit e5b0847

Please sign in to comment.