PV3D Memory

Three things: Getting a computer to serve a game, have it in Flash and use 3D techniques. Recently, whilst planning a project (secretly!) I was encouraged to create  a little memory game. Google helped and if found this. Since it’s Away3D I tried to get it running with PV3D. Initially with CUBEs I ran into performance problems. Now I use a DisplayObject3DContainer with two Plane objects (front and back) to get that thing up and running.

Well, I would make a tutorial but Yagiz Gurgul’s one is great to get the game logic. If anyone is interested in the PV3D constructor I am happy to post it here or provide a download… Here the snippet of the two-sided card:

private function makeTwoSidedDisplayObject(skin:String, id:int):DisplayObject3D {
			var do3d:DisplayObject3D = new DisplayObject3D();
			do3d.useOwnContainer = true;
			do3d.filters = [new DropShadowFilter()];

			var cardFront:Plane = makePlane(skin);
			var cardBack:Plane = makePlane('assets/back.png');			

// only the backside gets a listener for mouseEvents
			cardBack.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, planeClickedHandler);

// add the planes to the displayObject
			cardFront.rotationY = 180;
			cardBack.z = -1;
			do3d.id = id;

			// bend (uses the BEND MODIFIER CLASS)
			 var bendBack:Bend = new Bend(cardBack);
			 var bendFront:Bend  = new Bend(cardFront);
			cardBack.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, function() { bendBack.bend(Bend.X, Bend.Z, -0.5, 0.5); bendFront.bend(Bend.X, Bend.Z, 0.3, -0.3); Tweener.addTween(cardBack, { z: -15, transition:"easeOut" } ); } );
			cardBack.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, function() { bendBack.bend(Bend.X, Bend.Z, 0, 0); bendFront.bend(Bend.X, Bend.Z, 0, 0); Tweener.addTween(cardBack, { z: -1 } ); } );
			cardBack.addEventListener(InteractiveScene3DEvent.OBJECT_PRESS, function() { bendBack.bend(Bend.X, Bend.Z, 0, 0); bendFront.bend(Bend.X, Bend.Z, 0, 0);  } );

			return do3d;
		private function makePlane(skin:String):Plane {
			var bitmapMaterial:BitmapFileMaterial = new BitmapFileMaterial(skin);
			bitmapMaterial.interactive = true;
			bitmapMaterial.smooth = true;
			bitmapMaterial.tiled = true;
			var p:Plane = new Plane(bitmapMaterial, cardWidth, cardHeight, 6, 6);
			return p;

Actually it’s quite simple: creating two planes, having one set a bit back (cardBack.z = -1) and rotate it 180 degrees. By the way: the cardFront is actually turned down – so don’t get confused… The game has sound handlers as well and reads the content from a xml file.
Anyway – check it out and have fun! -> Brüno!


Deine Wirtschaft ist alles, Du bist nichts. Ein Auszug aus meinem Essay über den Weg von zynischen christlichen Werten zur anhaltenden Entfremdung in der Moderne. Was hat der Kapitalismus nun...
Give ‚em hell! Welcome to the Brave New World. Did you know that you can hire the US police for private reasons? Awesome "land of the free". On the other hand: w...
Demagogen und Gerechtigkeit #reichenhetze Der "Fetisch" Geld, also unser Glaube daran, hat unsere Zivilisation so weit ergriffen, dass wir dieses Mittel als ultimative Lösung unserer Probleme ...

Dieser Post ist auch verfügbar auf: Englisch