The MoBilliards application is a mobile version of the billiards game. It was developed with Flash Lite technology and use touch UI features. The game has a cool interface simulating a real billiards game.
This post shows how to use the Service API of the S60 5th edition for handling media files stored in the mobile phone.
First of all, it is necessary to create a Service class instance to access the media files. The constructor of the Service class receive two parameters, the first one is the class that implement the service (Service.MediaManagement) and the second one is the interface of this service.
// Import Platform Service Interfaceimport com.nokia.lib.Service;
/* ---------- getting Service ------------ */var media = new Service("Service.MediaManagement", "IDataSource");
Then, some parameters must be defined to access the correct resource:
A filter to get only images (The media management service can access audio and video files too)
var filter = {FileType:"Image"};
Order the result by the file name
varsort = {Key:"FileNameAndPath"};
Put all parameters in the same map (inParam) and call the GetList method of the ‘media’ object.
var inParam = {Type:"FileInfo", Filter:filter, Sort:sort};
media.GetList(inParam,onReceive);
The GetList method is asynchronous and a callback function must be defined. The ‘onReceive’ method defined in the second parameter of GetList method is the callback function. This function receive three parameters:
transactionID: The number to identifier the method call;
eventID: The number to identifier the event;
outParam: The return object.
The ‘onReceive’ function is show below:
var pathImages:Array = newArray();
function onReceive(transactionID:Number, eventID:String, outParam:Object){if(outParam.ErrorCode == 0){var outList = outParam.ReturnValue;
var outputEntry = null;
do{
outputEntry = outList.next();
if(null!= outputEntry){
pathImages.push(outputEntry.FileNameAndPath);
}else{
initialize();
break;
}}while(true);
}elsevar errorId = outParam.ErrorCode;
}//When all path images are get, the 'initialize' function is called. So, the movieClip Gallery load the images and show them.
function initialize():Void{_root.attachMovie('Gallery', 'gallery', _root.getNextHighestDepth());
gallery.Gallery(pathImages);
}
These applications were developed by undergraduate students in Computer Scienceat the Federal University of Campina Grande, Brazil. They use both the Flash Lite and Web Service technologies, see below more details about each application.
Project Domotic
With this application it is possible to access and control remotely devices, such as check temperature, turn on/off lights, doorknob and so on.
The architecture of this application is shown below. The clients may be written in different programming languages, in this case was used Flash Lite. The clients connect to a web service that provide the services available.
This application is most functional and quite promising because new features will be added making it more complete.
Quiz Zenith Application
This is a simple application that has a database question, with different levels. The user can retrieve the questions through a mobile application then answer them. At the end is given your score, it will also be stored for create a score ranking.
Making an analogy with the clock the 0° angle corresponds three hours, 90° angle it´s twelve hours and so on.
Remember that cosine function, defined as the ratio of the opposite side to the hypotenuse, the sine function as the ratio of the adjacent side to the hypotenuse and the tangent function
as the ratio of the opposite side to the adjacent side.
this is enough to understand the code below.
//Determining distance between center of balls with the Pytagorean theorem.
dx = ball1._x - ball2._x;
dy = ball1._y - ball2._y;
distance = Math.sqrt(dx * dx + dy * dy);
//If the distance is less than ball1.radius + ball2.radius, balls collided.if(distance <= (ball1.radius + ball2.radius)
collision(ball1, ball2);
function collision(ball1, ball2){
dx = ball1._x - ball2._x;
dy = ball1._y - ball2._y;
//Calculate the angle of collision with dy/dx
colision_angle = Math.atan2(dy, dx);
//Calculate the vector velocity of the both balls.
speed1 = Math.sqrt(ball1.vx* ball1.vx + ball1.vy* ball1.vy);
speed2 = Math.sqrt(ball2.vx* ball2.vx + ball2.vy* ball2.vy);
//Calculate the angle formed by vector velocity of each ball, knowing your direction.
direction1 = Math.atan2(ball1.vy, ball1.vx);
direction2 = Math.atan2(ball2.vy, ball2.vx);
//this step is needed because we have balls are moving on a 2D environment (picture 1), so rotating the component x of vector//velocity to overlapping the line formed by the center of balls, with this axis transformation the collision happens//in a 1D environment (picture 2): along the x axis.
vx_1 = speed1 *Math.cos(direction1 - colision_angle);
vy_1 = speed1 *Math.sin(direction1 - colision_angle);
vx_2 = speed2 *Math.cos(direction2 - colision_angle);
vy_2 = speed2 *Math.sin(direction2 - colision_angle);
//The only thing we need to solve is an elastic collision along one axis is a law of//conservation of momentum. Know that in an elastic collision total kinetic energy//is the same before and after the collision and total momentum remains constant throughout the//collision, whereas we have an isolated system.//speedAfterA = (speedBeforeA * (mA - mB) + 2 * mB * speedBeforeB)/(mA + mB)//speedAfterB = (speedBeforeB * (mB - mA) + 2 * mA * speedBeforeA)/(mA + mB)//if mA = mB, then://speedAfterA = speedBeforeB//speedAfterB = speedBeforeA
final_vx_1 = ((ball1.mass - ball2.mass)* vx_1 + (ball2.mass + ball2.mass)* vx_2)/(ball1.mass + ball2.mass);
final_vx_2 = ((ball1.mass + ball1.mass)* vx_1 + (ball2.mass - ball1.mass)* vx_2)/(ball1.mass + ball2.mass);
//Not change because this is an 1D environment collision.
final_vy_1 = vy_1;
final_vy_2 = vy_2
//It´s time to convert back the velocities to standard system cartesian. Math.PI/2 used because//the angle between vx and vy is always 90°.
ball1.vx = Math.cos(colision_angle)* final_vx_1 + Math.cos(colision_angle + Math.PI/2)* final_vy_1;
ball1.vy = Math.sin(colision_angle)* final_vx_1 + Math.sin(colision_angle + Math.PI/2)* final_vy_1;
ball2.vx = Math.cos(colision_angle)* final_vx_2 + Math.cos(colision_angle + Math.PI/2)* final_vy_2;
ball2.vy = Math.sin(colision_angle)* final_vx_2 + Math.sin(colision_angle + Math.PI/2)* final_vy_2;
}
This post is about a flash lite version of the popular Pac Man game. Pac Man was an arcade game released in 1980 by Namco.
In our Flash Lite version, the maze is read from XML files and the developer can customize it. You can download and try the beta version of this game here.