Hi Guys,
The following email from my work mate Vlad needs your help. He still
can't send to the yahoo group. Seemingly because he still hasn't been
approved. Please help us!!
Best,
Dan
---------
Hi there,
I am currently working on a mobile game for the 5800 nokia music
express, its a platform game and I'm trying to in corporate the use of
the accelerometer for the use of movement (eg tilt left to move left and
tilt right to move right)
But I keep getting really massive delays and lots of noise during tests
on the phone.
I have read the wiki pages on flash lite and accelerometer and have
followed there advice but even downloading the chart.swf file and
testing on the phone (the source code with no changes) generates delays.
Here is the source code I'm usng, it is the most reliable one I have
been able to find:
Source Code:
import com.nokia.lib.Service;
var sensors = new Service("Service.Sensor", "ISensor");
// Define input parameters for picking Rotation sensor
var inParam = {SearchCriterion:"Rotation"};
// Define result value
var outParams = sensors.FindSensorChannel(inParam);
// Define channel info (rotation)
var channelInfo = outParams.ReturnValue;
// Define valid values for channel info
var channelId = channelInfo[0].ChannelId;
var contextType = channelInfo[0].ContextType;
var quantity = channelInfo[0].Quantity;
var channelType = channelInfo[0].ChannelType;
var location = channelInfo[0].Location;
var vendorId = channelInfo[0].VendorId;
var dataItemSize = channelInfo[0].DataItemSize;
var channelDataTypeId = channelInfo[0].ChannelDataTypeId;
var channelInfo = {
ChannelId:channelId, ContextType:contextType, Quantity:quantity,
ChannelType:channelType, Location:location, VendorId:vendorId,
DataItemSize:dataItemSize, ChannelDataTypeId:channelDataTypeId
};
// Define input parameters for listening rotation channel data
var inParams = {ListeningType:"ChannelData", ChannelInfoMap:channelInfo};
// The RegisterForNotification method registers the user to receive data
from
// one sensor channel asynchronously
sensors.RegisterForNotification(inParams, callBack);
// Because this is an asynchronous method, you need to define the
callback function
// Callback function includes all the channel data
function callBack(transactionID:String, eventID:String, outParam:Object) {
var channelData = outParam.ReturnValue;
var xRot = channelData.XRotation;
var yRot = channelData.YRotation;
var zRot = channelData.ZRotation;
//text_txt.text = "x: "+xRot+"ry: "+yRot+"rz: "+zRot;
if(xRot < 90)
{
left_down = false;
right_down = true;
}
else if(xRot > 105)
{
left_down = true;
right_down = false;
}
else if (xRot == -1 || xRot == 90)
{
right_down = false;
left_down = false;
}
else
{
right_down = false;
left_down = false;
}
};
does any one know how to make the movement more stable, as at the moment
it is almost impossible to make the character stand still and perhaps
increase the response time to real time.
I'm running this at 20fps (reaching 100fps for this game would be
impossible) but running this code without the game and just printing the
x, y and z values to a text box seems to give very quick response time.
Any help or advice would be really appreciated,
Thanks to all in advance
Vlad