forked from kittykatattack/learningPixi
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64d296e
commit 0c9da1d
Showing
6 changed files
with
290 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!doctype html> | ||
<meta charset="utf-8"> | ||
<title>Make a sprite from and image</title> | ||
<body> | ||
<script src="../pixi.js/bin/pixi.js"></script> | ||
<script> | ||
|
||
//Create a Pixi stage and renderer and add the | ||
//renderer.view to the DOM | ||
var stage = new PIXI.Stage(0x000000) | ||
var renderer = PIXI.autoDetectRenderer( | ||
256, 256, | ||
{antialiasing: false, transparent: false, resolution: 1} | ||
); | ||
document.body.appendChild(renderer.view); | ||
|
||
//Use Pixi's built-in `AssetLoader` to load an image | ||
var loader = new PIXI.AssetLoader(["images/cat.png"]); | ||
loader.onComplete = setup; | ||
loader.load(); | ||
|
||
//Alternatively, you could use Pixi's `ImageLoader`, which | ||
//just loads images: | ||
/* | ||
var loader = new PIXI.ImageLoader("images/cat.png"); | ||
loader.onLoaded = setup.bind(this); | ||
loader.load(); | ||
*/ | ||
|
||
function setup() { | ||
|
||
//Create the `cat` sprite from the texture | ||
var texture = PIXI.TextureCache["images/cat.png"], | ||
cat = new PIXI.Sprite(texture); | ||
|
||
//Position the sprite and change its width and height | ||
cat.x = 96; | ||
cat.y = 96; | ||
|
||
//Optionally change the width and height | ||
cat.width = 80; | ||
cat.height = 120; | ||
|
||
//Optionally center the sprite's anchor point | ||
//cat.anchor.x = 0.5; | ||
//cat.anchor.y = 0.5; | ||
|
||
//Add the cat to the state | ||
stage.addChild(cat); | ||
|
||
//Render the stage | ||
renderer.render(stage); | ||
|
||
console.log(cat.getLocalBounds()); | ||
|
||
} | ||
</script> | ||
</body> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.