cocos2dx Windows Phone 10 game graphic quality - visual-studio

I am trying to clone a game for Windows phone. This is not for commerical.
I've created new cocos2dx win10 project with cocos creator. And tried to build and executed on Windows Phone 10 Lumia 935. But when I execute on real device, the graphic quality is lower than the original one. The 2 screenshots were attached.
I've setted screen resoulution to 800 x 480. And all images are not scaled.
This is the image on original game.
And this is the image on my new game.
Why these 2 image quality is different?
The original image is this.
What's the reason? I've read this article, but still not found correct answer.
https://github.com/cocos2d/cocos2d-x/issues/15901
The codes that I've implemented was added.
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
glview = GLViewImpl::createWithRect("RealHillClimb", cocos2d::Rect(0, 0, designResolutionSize.width, designResolutionSize.height));
#else
glview = GLViewImpl::create("RealHillClimb");
#endif
director->setOpenGLView(glview);
}
director->setAnimationInterval(1.0f / 180);
glview->setDesignResolutionSize(1280, 720, ResolutionPolicy::NO_BORDER);
auto frameSize = glview->getFrameSize();
int a = Device::getDPI();
if (frameSize.height > mediumResolutionSize.height)
{
director->setContentScaleFactor(MIN(largeResolutionSize.height/designResolutionSize.height, largeResolutionSize.width/designResolutionSize.width));
}
else if (frameSize.height > smallResolutionSize.height)
{
director->setContentScaleFactor(MIN(mediumResolutionSize.height/designResolutionSize.height, mediumResolutionSize.width/designResolutionSize.width));
}
else
{
director->setContentScaleFactor(MIN(smallResolutionSize.height/designResolutionSize.height, smallResolutionSize.width/designResolutionSize.width));
}
director->setContentScaleFactor(1);
cocos2d::Size dsize = glview->getDesignResolutionSize();
float d = director->getContentScaleFactor();
register_all_packages();
auto scene = SCNSplash::createScene();
director->runWithScene(scene);
return true;

Related

Xamarin Forms Adaptive Banner Ad Won't Load in Landscape

I recently upgraded from a Galaxy S6 to a Galaxy S21 Ultra and now the AdMob adaptive banner advert will not load in landscape. On the S6 it is fine, but on the S21 I get the error:
[Ads] Ad failed to load : 1
The code I use to create the advert is here:
private void NewAdaptiveBannerAd()
{
try
{
adAdaptiveBannerView = new AdAdaptiveBannerView();
adAdaptiveBannerView.Padding = new Thickness(0);
adAdaptiveBannerView.BackgroundColor = (Color)Application.Current.Resources["baseBackground_Light"];
AdGrid.Children.Add(adAdaptiveBannerView, 0, 1);
adAdaptiveBannerView.HeightRequest = getCurrentOrientationAnchoredAdaptiveBannerAdSize(Android.App.Application.Context, (int)(DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density));
static int getCurrentOrientationAnchoredAdaptiveBannerAdSize(Context context, int adWidth)
{
int var3 = 0;
if (context == null)
{
return 0;
}
else
{
int var7 = 2;
switch (DeviceDisplay.MainDisplayInfo.Orientation)
{
case DisplayOrientation.Unknown: var7 = 0; break;
case DisplayOrientation.Portrait: var7 = 1; break;
case DisplayOrientation.Landscape: var7 = 2; break;
default: return 0;
}
if (var3 == 0)
{
var3 = var7;
}
int var8 = var3 == var7 ? (int)Math.Round((float)DeviceDisplay.MainDisplayInfo.Height / DeviceDisplay.MainDisplayInfo.Density) : (int)Math.Round((float)DeviceDisplay.MainDisplayInfo.Width / DeviceDisplay.MainDisplayInfo.Density);
int var9 = (int)Math.Min(90, Math.Round((float)var8 * 0.15F));
int var10;
if (adWidth > 655)
{
var10 = (int)Math.Round((float)adWidth / 728.0F * 90.0F);
}
else if (adWidth > 632)
{
var10 = 81;
}
else if (adWidth > 526)
{
var10 = (int)Math.Round((float)adWidth / 468.0F * 60.0F);
}
else if (adWidth > 432)
{
var10 = 68;
}
else
{
var10 = (int)Math.Round((float)adWidth / 320.0F * 50.0F);
}
var10 = Math.Max(Math.Min(var10, var9), 50);
return var10;
}
}
}
catch (Exception)
{
Console.WriteLine("Creation of banner ad in SavedCharts failed.");
}
}
adAdaptiveBannerView is declared at the top of the pages class. The getCurrentOrientationAnchoredAdaptiveBannerAdSize function is from another post on here that I can't find now.
I can't find anything that would explain this, or why it would behave differently between these two 'phones (is it the difference in Android versions, the different aspect ratio or what?). Testing on the emulator is difficult because it doesn't report orientation correctly.
Does anyone have any idea what's going on?
My app will, by it's nature, mostly be used in landscape mode, so this problem means there's a chance many people won't see the adverts.
PS I'm using Xamarin.GooglePlayServices.Ads version 119.8.0. I haven't been able to implement version 120 because there's no documentation or anything that would help me do it.
Edit 1: I've tried conditionally adding an adaptive banner ad when in portrait, and a standard banner ad using MarcTron.Admob. It doesn't work.
I wondered if it's because the S21 Ultra's display is 1440 x 3200 pixels with an aspect ration of 20:9, and Google Ad Mob can't cope with it. It's rather stupid if that's the case ('adaptive'?!). So I tried giving it a screen width of 2560 on the basis that it worked on the S6 (1440x3200), and 1600 (i.e. half), but neither worked.
Edit 2: I realised I'd made a mistake when I tried limiting the screen width to 2560px, which was that I only did that for the height request of the view, whereas I also needed to do it for the AdSize property of the AdMob class itself. Anyway, that is the problem - adaptive banner ads can't cope with a display 3200px wide.
Google AdMab adaptive banner adverts cannot cope with a screen width of 3200px. I don't know what the actual limit is but since it works on my other device that has a screen width of 2560px I've limited it to that, like so:
adView.AdSize = AdSize.GetCurrentOrientationAnchoredAdaptiveBannerAdSize(Android.App.Application.Context, (int)(Math.Min(2560,DeviceDisplay.MainDisplayInfo.Width) / DeviceDisplay.MainDisplayInfo.Density));
and applied the same Math.Min() limiter to the code in my question.
The has the slightly unfortunate side-effect of a gap either side of the banner ad (3200-2560)/2=320 pixels wide. This doesn't violate Google's policies though (https://developers.google.com/admob/android/banner/adaptive).
I suggest this is a bug in Google's API (or at least the NuGet package), as an 'adaptive' ad that can't cope with all screen resolutions in real devices doesn't live up to its name.

Is this necessary to set frame Rate in Unity android game?

I want to know is it necessary to set application frame rate in Unity's android game script?
What is the best frame rate for android ? 30 fps or 60 fps ?
What if we do not set it? is it affect on game performance ?
Because my game has lag in some devices and it's genre is First Person Shooter.
Could it be because I did not specify the frame rate of the game?
Because I've been optimizing my game scripts as far as I can.
And in unity's profiller I checked my scripts and i didn't see any serious problem.
But some time's I have lag when i turning around. I mean when player looks around, some times he rotate about 180 degree or more quickly when lag is happening.
Here is part of my mouse look code :
void Update()
{
the_time = Time.deltaTime;
if (Input.touches.Length > 0)
{
foreach (Touch t in Input.touches)
{
if (t.position.x > Screen.width / 2)
{
if (t.phase == TouchPhase.Began)
{
delta = t.deltaPosition;
}
if (t.phase == TouchPhase.Began || t.phase == TouchPhase.Moved)
{
delta = -t.deltaPosition;
rotX += (delta.y * sensitivityX * current_speed_offset_vertical * the_time);
rotY -= delta.x * sensitivityY * current_speed_offset * the_time;
rotX = Mathf.Clamp(rotX, -clampAngle, clampAngle);
TlocalEurlar.y = rotY;
transform.eulerAngles = TlocalEurlar;
x_rot_transform_Eurlar.x = rotX;
x_rot_transform.localEulerAngles = x_rot_transform_Eurlar;
}
else if (t.phase == TouchPhase.Ended)
{
delta = t.deltaPosition;
}
}
}
}
}
Is there a problem with my script?
Can this problem be related to not setting the frame rate of the game?

Xamarin -- Set zoom in AVCapture not working

Hello I am trying to increase the zoom of the camera to its max level in my application.
However after setting the AvCapture to its max value it remains at its lowest zoom level on the screen. Below is my code.
void Initialize()
{
var videoDevices = AVCaptureDevice.DevicesWithMediaType(AVMediaType.Video);
var cameraPosition = (cameraOptions == CameraOptions.Front) ? AVCaptureDevicePosition.Front : AVCaptureDevicePosition.Back;
var device = videoDevices.FirstOrDefault(d => d.Position == cameraPosition);
device.LockForConfiguration(out error);
if (error == null)
{
Console.WriteLine("Supports Preset");
var test = device.RampingVideoZoom;
var d = device.VideoZoomFactor;
device.VideoZoomFactor = device.ActiveFormat.VideoMaxZoomFactor;
}
device.UnlockForConfiguration();
while(device.RampingVideoZoom == true)
{
Console.WriteLine("Zooming camera"); //This line is never written
}
//See below for value this returns in Console
Console.WriteLine("Current Format");
Console.WriteLine(device.ActiveFormat);
}
Current Format
<AVCaptureDeviceFormat: 0x1c48049a0 'vide'/'420v' 1920x1080, { 3- 30 fps}, HRSI:4096x2304, fov:59.680, supports vis, max zoom:16.00 (upscales #1.94), AF System:2, ISO:22.0-704.0, SS:0.000005-0.333333>
This code does not affect the zoom of the camera AT ALL.
What am I doing wrong?
videoMaxZoomFactor Definition
A maximum factor of 1.0 indicates that the format is not capable of zooming.
There is no mistake in your code.
As the Documentation said ,if device.ActiveFormat.VideoMaxZoomFactor == 1 ,the zoom is not available.
You can debug the value of device.ActiveFormat.VideoMaxZoomFactor to see if it euqals to 1.

Game Maker - Freezing an sprite on animation end

When the player dies, I want the sprite to stop animating on the last frame.
I tried this on Animation End event
if (sprite_index == spr_ninja_dead) {
image_speed = 0;
image_index = image_number - 1;
}
I also tried this
if (sprite_index == spr_ninja_dead) {
image_speed = 0;
image_index = 9;
}
This is the recommended way that GM suggests, yet the sprite freezes on the first sub image. What am I doing wrong?
When the player gets hit, the sprite would change to a flashing sprite image. Then an alarm would change it back to normal. I added an if statement to fix this:
if (sprite_index = spr_ninja_flash){
sprite_index = spr_ninja_idle;
}
What you want to do is run the animation first.
So try this:
if( sprite_index == spr_ninja_dead ){
if( image_index == image_number ){ // This will check if the image is the last image of the sprite
image_speed = 0;
}
}
First you check if the sprite is the dead one, then you check if it's the last image of the sprite and if that is the case you can pause the animation using the image speed.

GPS accuracy Issues

I am developing a windows phone sports tracker app, that uses gps sensors to calculate the distance travelled by the runner, I am using geocoordinatewatcher class for the same, setting the movement threshold to 100. But, I find my app giving distance values even when the device is kept stationary. My app should give distance only when the device changes its position. I found the same bug in othere apps that are on the marketplace, please tell me where am I doing wrong?
My Code.
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.MovementThreshold = 150;
watcher.PositionChanged += watcher_PositionChanged;
watcher.Start();
{
latitudeCurrent = e.Position.Location.Latitude;
longitudeCurrent = e.Position.Location.Longitude;
if (stepCounter == 0)
{
latitudePrevious = latitudeCurrent;
longitudePrevious = longitudeCurrent;
distanceTravelled += Math.Round(Calculate(latitudePrevious,longitudePrevious,latitudeCurrent,longitudeCurrent),2);
txbDistanceTravelled.Text = distanceTravelled.ToString();
txbCalories.Text=string.Format("{0:f0}", distanceTravelled * 65);
stepCounter++;
var millisPerKilometer = (distanceTravelled) * (System.Environment.TickCount - _previousPositionChangeTick);
txbPace.Text = TimeSpan.FromMilliseconds(millisPerKilometer).ToString(#"mm\:ss");
double hrs = counterTick / 3600;
if (!double.IsNaN((distanceTravelled / hrs)))
{
txbSpeed.Text = (distanceTravelled / hrs).ToString();
}
else
{
txbSpeed.Text = "0";
}
}
}
You are developing your app for Windows Phone 7 or Windows Phone 8? IF you are developing for the later, you need to use the new Geolocator class and not GeoCoordinateWatcher.
Also, as LewisBenge said, if you are testing This indoor you can get WiFi positions or even cellular data. It could be better to test outdoor.
Your GPS signal might be weak in the place where you are testing. Try it in the outdoor location.

Resources