-
Notifications
You must be signed in to change notification settings - Fork 193
Update all examples to use PIXI.Application, remove v3 examples #24
Conversation
"title": "Custom Filter", | ||
"entry": "custom-filter.js" | ||
} | ||
], | ||
"demos": [ | ||
{ | ||
"title": "MovieClip", | ||
"title": "AnimatedSprite", | ||
"entry": "movieclip-demo.js" |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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(); | ||
}); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
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. |
Great review @themoonrat, I don't disagree with any of your comments. Thanks for digging in. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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 |
@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. |
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) |
Ok, ignore; I had to set up a mime type for .frag and .atlas on my webserver. All good now :) |
@bigtimebuddy same background is used in pictures |
Changes
PIXI.Application
API in the latest version of PIXIposition
point with x, y getters/setters