create hand with variable cards.
This commit is contained in:
		@ -1,5 +1,5 @@
 | 
			
		||||
import { Application, Assets, Sprite } from "pixi.js";
 | 
			
		||||
import { Hand } from "./hand";
 | 
			
		||||
import { Hand } from "./Hand";
 | 
			
		||||
 | 
			
		||||
(async () => {
 | 
			
		||||
	// Create a new application
 | 
			
		||||
@ -12,31 +12,18 @@ import { Hand } from "./hand";
 | 
			
		||||
	document.getElementById("pixi-container")!.appendChild(app.canvas);
 | 
			
		||||
 | 
			
		||||
	try {
 | 
			
		||||
		// Create the SpriteSheet from data and image
 | 
			
		||||
		const cards = await Assets.load("/public/assets/cards.json");
 | 
			
		||||
		const hand = new Hand(1000, [
 | 
			
		||||
			"fourOfDiamonds",
 | 
			
		||||
			"eightOfDiamonds",
 | 
			
		||||
			"threeOfClubs",
 | 
			
		||||
			"kingOfSpades",
 | 
			
		||||
		]);
 | 
			
		||||
 | 
			
		||||
		console.log(cards);
 | 
			
		||||
 | 
			
		||||
		// Create a bunny Sprite
 | 
			
		||||
		const bunny = new Sprite(cards.textures["fourOfHearts"]);
 | 
			
		||||
 | 
			
		||||
		console.log(bunny);
 | 
			
		||||
 | 
			
		||||
		// Center the sprite's anchor point
 | 
			
		||||
		bunny.anchor.set(0.5);
 | 
			
		||||
 | 
			
		||||
		// Move the sprite to the center of the screen
 | 
			
		||||
		bunny.position.set(app.screen.width / 2, app.screen.height / 2);
 | 
			
		||||
 | 
			
		||||
		bunny.height /= 1.5;
 | 
			
		||||
		bunny.width /= 1.5;
 | 
			
		||||
 | 
			
		||||
		// Add the bunny to the stage
 | 
			
		||||
		// app.stage.addChild(bunny);
 | 
			
		||||
 | 
			
		||||
		const hand = new Hand(["fourOfDiamonds"]);
 | 
			
		||||
		app.stage.addChild(hand.cards);
 | 
			
		||||
 | 
			
		||||
		hand.cards.position.set(app.screen.width / 2, 0);
 | 
			
		||||
		hand.cards.pivot.set(hand.cards.width / 2, 0);
 | 
			
		||||
 | 
			
		||||
		// Listen for animate update
 | 
			
		||||
		// app.ticker.add((time) => {
 | 
			
		||||
		// 	// Just for fun, let's rotate mr rabbit a little.
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user