Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Update all examples to use PIXI.Application, remove v3 examples #24

Merged
merged 16 commits into from
Jan 27, 2017

Conversation

bigtimebuddy
Copy link
Member

@bigtimebuddy bigtimebuddy commented Jan 23, 2017

Changes

  • Updated to use the PIXI.Application API in the latest version of PIXI
  • Removes the v3 examples
  • Removes _details.json, which are unneeded
  • Fixes the size of the RenderTexture example
  • Replace the use of position point with x, y getters/setters
  • Use pointer events instead of mouse & touch
  • Added tap/click-to-start for the video example

"title": "Custom Filter",
"entry": "custom-filter.js"
}
],
"demos": [
{
"title": "MovieClip",
"title": "AnimatedSprite",
"entry": "movieclip-demo.js"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth changing filename?

// create a MovieClip (brings back memories from the days of Flash, right ?)
movie = new PIXI.extras.MovieClip(frames);
var movie = new PIXI.extras.AnimatedSprite(frames);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change var name and comment below about what a movie clip is

var texture = PIXI.Texture.fromFrame('Explosion_Sequence_A ' + (i+1) + '.png');
explosionTextures.push(texture);
}

for (i = 0; i < 50; i++)
{
for (i = 0; i < 50; i++) {
// create an explosion MovieClip
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another movie clip reference


// Listen for animate update
app.ticker.add(function() {
// just for fun, let's rotate mr rabbit a little
bunny.rotation += 0.1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to show best practice by using time delta here for a frame rate independent transform?

requestAnimationFrame(animate);

// Listen for animate update
app.ticker.add(function() {
//rotate the container!
container.rotation -= 0.01;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to show best practice by using time delta here for a frame rate independent transform?

}
app.stage.addChild(pic);
app.start();
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No end of file new line?

// create the root of the scene graph
var stage = new PIXI.Container();
var app = new PIXI.Application(800, 600, { transparent: true });
document.body.appendChild(app.view);

// create a video texture from a path
var texture = PIXI.Texture.fromVideo('testVideo.mp4');

// create a new Sprite using the video texture (yes it's that easy)
var moveSprite = new PIXI.Sprite(texture);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this was supposed to be movieSprite rather than moveSprite?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this demo, it wasn't being used. basics/video.js is used instead.

stage.addChild(textSample);
stage.addChild(spinningText);
stage.addChild(countingText);
app.stage.addChild(textSample);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addChild these all together


// make the button interactive...
button.interactive = true;



button
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to demonstrate pointer events alongside mouse and touch for interactivity guide?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better and easier to use pointer events because it's covers both. I'm going to comment out the mouse and touch events.

// create the root of the scene graph
var stage = new PIXI.Container();
var app = new PIXI.Application(800, 600, { transparent: true });
document.body.appendChild(app.view);

// create a video texture from a path
var texture = PIXI.Texture.fromVideo('required/assets/testVideo.mp4');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to require a 'play'touch, which goes through baseTexture to call play on html video so that this works on iPhones

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you do this?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the texture automatically being created and added to the stage, on initial load this would not be the case; there would just be a 'play' sprite. When this is pressed, it would disappear, and then create the video texture, adding to a sprite, adding to the stage etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@themoonrat added click to play for the video example

@themoonrat
Copy link
Collaborator

There's some things you might not think worth changing, but raised them anyway. There are some common things... Showing addChild with multiple parameters, using pointer events rather than mouse and touch etc. Might be some i missed there, but you might not care so that's fine!

I also added in one place for consideration, but applies to lots of them.... should our demos demonstrate frame rate independence when hooking into the ticker callback for transforms on screen.

@bigtimebuddy
Copy link
Member Author

Great review @themoonrat, I don't disagree with any of your comments. Thanks for digging in.

@bigtimebuddy bigtimebuddy mentioned this pull request Jan 25, 2017
Copy link
Collaborator

@themoonrat themoonrat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple of little comments.
Also

  • demos/blendmodes.js demo background doesn't fill the screen? Looks slightly to the left of where it should be
  • custom-filter.js demo does not work at all
  • no demos from spine/ or textures/ work


stage.addChild(videoSprite);
// Listen for a click/tap event to start playing the video
// this is useful for some mobile platforms
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Listen for a click/tap event to start playing the video
// this is useful for some mobile platforms. For example:
// ios9 and under cannot render videos in PIXI without a polyfill - https://github.com/bfred-it/iphone-inline-video
// ios10 and above require a click/tap event to render videos that contain audio in PIXI. Videos with no audio track do not have this requirement

fontSize: 36,
fontStyle: 'italic',
fontWeight: 'bold',
fill: ['#ffffff', '#fff0b5'], // gradient
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if the difference in colours was a bit more pronounced. I couldn't tell that one was set

@ivanpopelyshev
Copy link
Contributor

ivanpopelyshev commented Jan 27, 2017

  • demos/blendmodes.js demo background doesn't fill the screen? Looks slightly to the left of where it should be

It was like that in v3.

I'll look at bit later whats it with spine and textures. I know that textures were working but they were a bit wrong, I'll fix it

@bigtimebuddy
Copy link
Member Author

@themoonrat Fixed the blendmodes background. Must've missed that.

custom-filter and the spine/texture examples all worked for me. Did you making sure you clear your browser cache? Not sure what could be the issue there.

@themoonrat
Copy link
Collaborator

themoonrat commented Jan 27, 2017

I have cleared browser cache (have chrome dev tools open to clear on refresh)

For the custom filter I get the following error

Resource.js:593 GET http://localhost/pe/required/assets/basics/shader.frag 404 (Not Found)
2017-01-27 13:43:07.320 compileProgram.js:56 WebGL: INVALID_VALUE: shaderSource: string not ASCII
compileShader @ compileProgram.js:56
compileProgram @ compileProgram.js:13
Shader @ GLShader.js:31
Shader @ Shader.js:45
applyFilter @ FilterManager.js:225
apply @ Filter.js:108
popFilter @ FilterManager.js:157
renderAdvancedWebGL @ Container.js:460
renderWebGL @ Container.js:386
renderWebGL @ Container.js:395
render @ WebGLRenderer.js:284
render @ Application.js:68
emit @ index.js:150
update @ Ticker.js:320
Ticker._tick @ Ticker.js:128
requestAnimationFrame (async)
_requestIfNeeded @ Ticker.js:152
start @ Ticker.js:257
start @ Application.js:84
onLoaded @ VM2797:28
dispatch @ mini-signals.js:93
_onComplete @ Loader.js:569
(anonymous) @ Loader.js:609
next @ async.js:26
bitmapFontParser @ bitmapFontParser.js:6
(anonymous) @ Loader.js:591
next @ async.js:32
spritesheetParser @ spritesheetParser.js:12
(anonymous) @ Loader.js:591
next @ async.js:32
textureParser @ textureParser.js:24
(anonymous) @ Loader.js:591
next @ async.js:32
blobMiddleware @ blob.js:84
(anonymous) @ Loader.js:591
next @ async.js:32
eachSeries @ async.js:33
_onLoad @ Loader.js:590
dispatch @ mini-signals.js:93
complete @ Resource.js:356
_xhrOnLoad @ Resource.js:782
XMLHttpRequest.send (async)
_loadXhr @ Resource.js:593
load @ Resource.js:454
(anonymous) @ Loader.js:554
next @ async.js:26
eachSeries @ async.js:33
_loadResource @ Loader.js:543
Loader._boundLoadResource @ Loader.js:129
process @ async.js:108
resume @ async.js:137
load @ Loader.js:481
window.onload @ VM2797:14
2017-01-27 13:43:07.321 compileProgram.js:61 ERROR: 0:? : '' : syntax error
Uncaught TypeError: Failed to execute 'attachShader' on 'WebGLRenderingContext': parameter 2 is not of type 'WebGLShader'.
at compileProgram (compileProgram.js:18)
at Shader (GLShader.js:31)
at new Shader (Shader.js:45)
at FilterManager.applyFilter (FilterManager.js:225)
at Filter.apply (Filter.js:108)
at FilterManager.popFilter (FilterManager.js:157)
at Sprite.renderAdvancedWebGL (Container.js:460)
at Sprite.renderWebGL (Container.js:386)
at Container.renderWebGL (Container.js:395)
at WebGLRenderer.render (WebGLRenderer.js:284)

@themoonrat
Copy link
Collaborator

themoonrat commented Jan 27, 2017

Ok, ignore; I had to set up a mime type for .frag and .atlas on my webserver. All good now :)

@ivanpopelyshev
Copy link
Contributor

@bigtimebuddy same background is used in pictures

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants