Skip to content

Commit

Permalink
feat: rename scene-base to scene-ssr, improve docs, types
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Piętal committed May 22, 2024
1 parent 7676ea5 commit 0ed9fb6
Show file tree
Hide file tree
Showing 76 changed files with 622 additions and 492 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ npm i @jacekpietal/oneforall --save
✓ THEN it can't have zero radius (9 ms)
✓ THEN update propagates x/y changes
PASS src/scene-base.spec.ts
PASS src/scene-ssr.spec.ts
GIVEN SceneBase
✓ THEN it works (3 ms)
✓ THEN it can have children (1 ms)
Expand Down
3 changes: 3 additions & 0 deletions dist/animator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export declare class Animator extends PIXI.Container implements LifecycleProps {
* Reference to inner animation scale.
*/
get scale(): PIXI.ObservablePoint;
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime: number): void;
setScale(x?: number, y?: number): void;
getAnimationIndex(state: string): number;
Expand Down
2 changes: 1 addition & 1 deletion dist/animator.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions dist/animator.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class Animator extends PIXI.Container {
texture.source.scaleMode = 'nearest';
return { texture, time: animationSpeed };
}));
animatedSprite.label = 'Animator_AnimatedSprite';
animatedSprite.anchor.set(anchor.x, anchor.y);
this.addChild(animatedSprite);
});
Expand All @@ -89,6 +90,9 @@ class Animator extends PIXI.Container {
get scale() {
return this.animation.scale;
}
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime) {
this.x = this.gameObject.x;
this.y = this.gameObject.y;
Expand Down
3 changes: 3 additions & 0 deletions dist/circle-body.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export declare class CircleBody extends Ellipse implements LifecycleProps {
*/
label: string;
constructor(gameObject: GameObject, radiusX: number, radiusY?: number, step?: number, options?: BodyOptions);
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime: number): void;
destroy(): void;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/circle-body.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/circle-body.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class CircleBody extends detect_collisions_1.Ellipse {
}
gameObject.addChild(this);
}
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime) {
this.gameObject.x = this.x;
this.gameObject.y = this.y;
Expand Down
3 changes: 3 additions & 0 deletions dist/component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export declare class Component implements LifecycleProps {
*/
label: string;
constructor(gameObject: GameObject);
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime: number): void;
destroy(): void;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/component.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class Component {
this.label = 'Component';
gameObject.addChild(this);
}
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime) {
lifecycle_1.Lifecycle.update(this, deltaTime);
}
Expand Down
3 changes: 3 additions & 0 deletions dist/container.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export declare class Container extends PIXI.Container implements LifecycleProps
*/
label: string;
constructor(gameObject: LifecycleParent);
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime: number): void;
destroy(): void;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/container.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class Container extends PIXI.Container {
this.label = 'Container';
gameObject.addChild(this);
}
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime) {
this.x = this.gameObject.x;
this.y = this.gameObject.y;
Expand Down
7 changes: 5 additions & 2 deletions dist/game-object.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { CircleBody } from './circle-body';
import { Lifecycle, LifecycleProps } from './lifecycle';
import { Prefab } from './prefab';
import { Scene } from './scene';
import { SceneBase } from './scene-base';
import { SceneSSR } from './scene-ssr';
export interface TGameObject<TSprite = Animator, TBody = CircleBody> extends GameObject {
body: TBody;
sprite: TSprite;
target?: Vector;
}
export type SceneType = SceneBase | Scene;
export type SceneType = SceneSSR | Scene;
export type GameObjectParent = SceneType | GameObject;
export declare const getRoot: (gameObject: GameObject) => SceneType | undefined;
export declare class GameObject extends Lifecycle {
Expand Down Expand Up @@ -47,6 +47,9 @@ export declare class GameObject extends Lifecycle {
* get parent scene if exists
*/
get scene(): SceneType | undefined;
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime: number): void;
destroy(): void;
recursive(child: LifecycleProps, callback: (deep: LifecycleProps) => void): void;
Expand Down
2 changes: 1 addition & 1 deletion dist/game-object.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/game-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class GameObject extends lifecycle_1.Lifecycle {
get scene() {
return (0, exports.getRoot)(this);
}
/**
* @param deltaTime = 1.0 for 60FPS
*/
update(deltaTime) {
this.children.forEach((child) => {
child.update(deltaTime);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export * from './container';
export * from './animator';
export * from './game-object';
export * from './prefab';
export * from './scene-base';
export * from './scene-ssr';
export * from './scene';
export * from './application';
export * from './resources';
Expand Down
2 changes: 1 addition & 1 deletion dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ __exportStar(require("./container"), exports);
__exportStar(require("./animator"), exports);
__exportStar(require("./game-object"), exports);
__exportStar(require("./prefab"), exports);
__exportStar(require("./scene-base"), exports);
__exportStar(require("./scene-ssr"), exports);
__exportStar(require("./scene"), exports);
__exportStar(require("./application"), exports);
__exportStar(require("./resources"), exports);
Expand Down
9 changes: 6 additions & 3 deletions dist/lifecycle.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as PIXI from 'pixi.js';
import { Subject } from 'rxjs/internal/Subject';
import { GameObject, GameObjectParent } from './game-object';
import { Scene } from './scene';
import { SceneBase } from './scene-base';
export type LifecycleParent = GameObject | SceneBase | Scene | PIXI.Container;
import { SceneSSR } from './scene-ssr';
export type LifecycleParent = GameObject | SceneSSR | Scene | PIXI.Container;
export type LifecycleChild = GameObject | PIXI.Container;
export interface LifecycleProps {
/**
Expand All @@ -26,7 +26,7 @@ export interface LifecycleProps {
*/
label: string;
/**
* Updates the Lifecycle Object with actual deltaTime ~60fps
* Updates the Lifecycle with actual deltaTime = 1.0 for 60FPS
*/
update(deltaTime: number): void;
/**
Expand Down Expand Up @@ -60,6 +60,9 @@ export declare abstract class Lifecycle implements LifecycleProps {
static destroy(lifecycle: LifecycleProps): void;
static update(lifecycle: LifecycleProps, deltaTime: number): void;
destroy(): void;
/**
* Updates the Lifecycle with actual deltaTime = 1.0 for 60FPS
*/
update(deltaTime: number): void;
}
//# sourceMappingURL=lifecycle.d.ts.map
Loading

0 comments on commit 0ed9fb6

Please sign in to comment.