Jan 13

This is a new request from one of my friend Yuki. She showed me a Flash Website Tracy Chapman with a very nice Colour Fill Feature.

It’s quite easy to implement in Flash. However, it’s much more difficult in Silverlight since I am not familiar with the Microsoft Expression Design. Therefore, I just implemented a simple version for the Silverlight. (See if anyone could help me to make a similar one as in Flash. But I think it’s very very difficult to make it.)

This color fill technique can even applied to animation. I will try to implement it if people really find it useful.

Comparison

Flash implementation: 1 hour (Implemented First)
Silverlight implementation: 50 minutes

Source codes

Flash

Silverlight

(This is a simple version. It will apply a random color for each click.)

My Design

This is one of my design using the above application. Hope you like it~

Flash vs Silverlight Gallery

Jan 07

This is a new request by Benoit. He said he doesn’t know how to detect double click in Silverlight. Well, the answer is simple, Silverlight doesn’t have any support for double clicking yet.

Is it funny? Anyway, there still a lot of methods and work around to simulate double click. Today, I will show you one.

Not only double clicking, Silverlight doesn’t have native support for mouse scroll as well. However, I think the problems will be solved in Silverlight 3. Let’s look forward!

Comparison

Flash implementation: 20 minutes

Silverlight implementation: 30 minutes (Implemented First)

Source codes

Flash

Silverlight

Jan 03

Happy New Year! I have played for almost 5 days. Time to get started for Shine Draw again!

This is an enhanced version from the Simple Game System. A road background is added to the game and the car can eat up the “food” on the road.

I believe it is a good sample for your amazing Silverlight Game! Enjoy it~

Comparison

Flash implementation: 25 minutes
Silverlight implementation: 1 hour 35 minutes (Implemented First)
What’s the difference?

  • Hit Test: hitTestObject [AS3] vs FindElementsInHostCoordinates [C#]

Source codes

Flash

Silverlight

Hit Test: hitTestObject [AS3] vs FindElementsInHostCoordinates [C#]

In Flash, you may use hitTestObject or hitTestPoint to test for the collision of objects or points. I think the ease of the methods bring many Flash Games into the Internet. Below is a simple sample showing how to check all the collisions of food with the car.

// AS3
// _foodContainer is a MovieClip holding all the food
for(var i:int = 0; i < _foodContainer.numChildren; i++){
	var food : DisplayObject = _foodContainer.getChildAt(i);
	if(_car.hitTestObject(food)){
		// Hit!!
	}
}

Story is completely different in Silverlight. There is no object testing method similar to Flash. Instead, you can only collect all the objects by specifying a given point. Well, I don’t have too much comment on that. I will let the users to judge which approach is better.

Below is a simple example.

// C#
// get the car position
int carX = Convert.ToInt32( (double) Car.GetValue(Canvas.LeftProperty));
int carY = Convert.ToInt32((double) Car.GetValue(Canvas.TopProperty));
Point ptCheck = new Point();

// check all the points around the car
for (int x = carX; x < carX + Car.Width; x+=5)
{
    for (int y = carY; y < carY + Car.Height; y+=5)
    {
        ptCheck.X = x;
        ptCheck.Y = y;

        // get all the elements on that points
        List hits = System.Windows.Media.VisualTreeHelper.FindElementsInHostCoordinates(ptCheck, LayoutRoot) as List;

        // check throught all the food
        for(int i = 0; i < FoodContainer.Children.Count; i++){
            Food food = FoodContainer.Children[i] as Food;
            if (hits.Contains(food))
            {
                // Hit!!
            }
        }
    }
}
Dec 24

Personally, I really love Christmas. You can see that most of the samples I shared recently are linked to Christmas.

Anyway, the sample today probably will be the last one in the Christmas series. It is a Christmas Ecard I created (again, many years ago) for a Christmas Ecard Competition.

Well, only one day left for Xmas! Remember to send your E-card Greeting at Pencake Christmas Ecard!

Demo

Source codes

Flash

Dec 20

Finally, I have completed the 3D Image Rotator using Kit3D. If you are looking for a quick way to make a real 3D flipping rotator, this must be your choice.

Well, this time, I only got the Silverlight sample only. That’s because it really takes a lot of time to deal with 3D Graphics. I am sure I will launch the Flash demo very soon.

Images used in the application below are collected from Smashing Magazine - Christmas Wallpapers.

Demo

Source codes

Silverlight

 
(I have included a Christmas Song “Santa Claus is coming to town” inside the demo. Hope you enjoy it.)