I have an application in Titanium for Android and iOS and it works ok. Now, I want to create the blackberry version.
In my app, I rotate some elements to create the interface.
For this, I use:
var matrix = Ti.UI.create2DMatrix();
matrix = matrix.rotate(value);
animationRotate = Ti.UI.createAnimation({
transform : matrix,
duration : duration,
autoreverse : false,
repeat : 0
});
animationRotate.anchorPoint = {
x : xAnchorPoint,
y : yAnchorPoint
};
element.anchorPoint = {
x : xAnchorPoint,
y : yAnchorPoint
};
element.animate(animationRotate);
I've tried it on Blackberry simulator and I receive an error: Ti.UI.create2DMatrix NOT SUPPORTED IN BB10 (as it's said in documentation).
How can I rotate an element in BB10?
Thank you very much
Related
I have tried creating a game in unity and build it on ios on any apple devices there were no problem except on iphone x. Screenshot is below.enter image description here. It was covered by the iphone x notch and then when when the character is on the left or the right side it was cut it half.Is there any other solution or a plugin we can use to solve the issue ?. Is there a unity settins or xcode settings to that ? .Thank You
About the iPhone X notch, you can use this:
Screen.safeArea
It is a convenient way to determine the screen actual "Safe Area". Read more about it in this thread.
About the character cutting in half, this is probably something you need to take care of manually based on your game logic. By getting the Screen.width - you should be able to either adjust the Camera (zoom out) or limit the character movement in a way that it will not get past the screen edge.
For the iPhone X and other notched phones you can use the generic Screen.safeArea provided by Unity 2017.2.1+. Attach the script below to a full screen UI panel (Anchor 0,0 to 1,1; Pivot 0.5,0.5) and it will shape itself to the screen safe.
Also recommended to have your Canvas set to "Scale With Screen Size" and "Match (Width-Height)" = 0.5.
public class SafeArea : MonoBehaviour
{
RectTransform Panel;
Rect LastSafeArea = new Rect (0, 0, 0, 0);
void Awake ()
{
Panel = GetComponent<RectTransform> ();
Refresh ();
}
void Update ()
{
Refresh ();
}
void Refresh ()
{
Rect safeArea = GetSafeArea ();
if (safeArea != LastSafeArea)
ApplySafeArea (safeArea);
}
Rect GetSafeArea ()
{
return Screen.safeArea;
}
void ApplySafeArea (Rect r)
{
LastSafeArea = r;
Vector2 anchorMin = r.position;
Vector2 anchorMax = r.position + r.size;
anchorMin.x /= Screen.width;
anchorMin.y /= Screen.height;
anchorMax.x /= Screen.width;
anchorMax.y /= Screen.height;
Panel.anchorMin = anchorMin;
Panel.anchorMax = anchorMax;
}
}
For a more in depth breakdown, I've written a detailed article with screenshots here: https://connect.unity.com/p/updating-your-gui-for-the-iphone-x-and-other-notched-devices. Hope it helps!
Sorry for the late answer but I have adjusted the camera's viewport rectangle for iOS devices and it works correctly. Check if it works for your camera as well.
I have tried safeArea and other script based solutions which do not seem to work.
#if UNITY_IPHONE
mainCamera.rect = new Rect(0.06f, 0.06f, 0.88f, 1);
#endif
In my web application I utilize this beautiful 3D scatter chart rendered using Highcharts.
It does rotate nicely using the mouse by clicking on it and dragging around.
However, on neither my phone nor my tablet it does rotate also.
The code for enabling rotation looks as follows (adopted from the Highcharts sample page):
// Add mouse events for rotation
$(chart.container).on('mousedown.hc touchstart.hc', function (eStart) {
eStart = chart.pointer.normalize(eStart);
var posX = eStart.pageX,
posY = eStart.pageY,
alpha = chart.options.chart.options3d.alpha,
beta = chart.options.chart.options3d.beta,
newAlpha,
newBeta,
sensitivity = 5; // lower is more sensitive
$(document).on({
'mousemove.hc touchdrag.hc': function (e) {
// Run beta
newBeta = beta + (posX - e.pageX) / sensitivity;
chart.options.chart.options3d.beta = newBeta;
// Run alpha
newAlpha = alpha + (e.pageY - posY) / sensitivity;
chart.options.chart.options3d.alpha = newAlpha;
chart.redraw(false);
},
'mouseup touchend': function () {
$(document).off('.hc');
}
});
});
I assume that the events where this logic is registered are not available on my devices (recent Samsung Galaxy Tab and Samsung Galaxy S5).
Any ideas?
The problem is, a touch event doesn't have pageX or pageY. Instead of using event.pagePosition, you should use event.chartPosition. And chartPositions are only available after normalized by chart.pointer.normalize.
Also, there is no touchdrag event, it should be touchmove
I'm a young developer who's school project went viral amongst my school and then was turned into an app. I'm using Phonegap as I'm most advanced in web languages. I decided to cater for all devices, but originally built it for iPhone layout. To make it look good on iPad, I used Cordova device detection to implement my changes (I know this is bad) like this:
//Checks what device is being used
var deviceType = (navigator.userAgent.match(/iPad/i)) == "iPad" ? "iPad" : (navigator.userAgent.match(/iPhone/i)) == "iPhone" ? "iPhone" : (navigator.userAgent.match(/Android/i)) == "Android" ? "Android" : (navigator.userAgent.match(/BlackBerry/i)) == "BlackBerry" ? "BlackBerry" : "null";
//Width & Height for Tannock Image
var width = 178.5;
var height = 270;
//If device is iPad
if(deviceType == "iPad"){
$('#teaImg').css('height', '540px');
$('#teaImg').css('width', '357px');
$('#text1').css('margin-left', '38%');
$('#text1').css("font-size", '35px');
width = 357;
height = 270;
}
This shocking code was working absolutely fine when I directly fed it to my iPad through Xcode, but when I downloaded it from the app store, this was no longer working and so instead of looking like I wanted it to, it didn't apply any of these changes.
Does anyone know how to fix this?
P.s The app is called Tannock Tapper, I know it's buggy, I'm a one man team and school takes priority.
I fixed my code according to device orinted as following:
I Set you code in my format for your use.
var isAndroid = navigator.userAgent.match(/android/i) ? true : false;
var isIPhone = navigator.userAgent.match(/iphone/i) ? true : false;
var isIPad = navigator.userAgent.match(/ipad/i) ? true : false;
var isBlackberry = (navigator.userAgent.match(/BlackBerry/i)) ? true : false;
var width = 178.5;
var height = 270;
//If device is iPad
if(isIPad){
$('#teaImg').css('height', '540px');
$('#teaImg').css('width', '357px');
$('#text1').css('margin-left', '38%');
$('#text1').css("font-size", '35px');
width = 357;
height = 270;
}
// If device is android
if(isAndroid){
// android related code
}
if(isBlackberry){
// Black berry related code.
}
i also have same code in my app and i am using this code from last 3 years in my app which is already in app store.
Ping me if looks confusing.
I want to implement Xamarin forms image zoom property. I did search the internet for quite some time but I didn't find any relevant documentation, can anyone provide me some information on how to implement it in Xamarin Forms?
Currently there is no zoom property for image. You have to use custom renderer to acheive that.
Try using ScaleTo, Itz similar to zoom but not exactly zoom functionality.. Hope it helps...
var img = new Image {
Source = "foo.png",
Scale = .9
};
var stepper = new Stepper {
Minimum = .1,
Maximum = 1,
Increment = .1,
Value = .9,
};
stepper.ValueChanged += async (object sender, ValueChangedEventArgs e) => {
img.ScaleTo(e.NewValue);
};
I had the same need to implement zoom, click, ... on images on Xamarin Forms.
On the forum i find a plugin that define custom renderers for the 3 platforms that can allow you to get coordinates of click on image and then to implement the zoom you want to do.
Here the website of the plugin : http://www.mrgestures.com/
It costs 10euros for every application you develop. Depending on what you need to implement and how many times you will need it it's not expensive at all.
The issue comes with scale property that its scaled to the center of x and y ,
I've implemented this extension no need for extra renderer.
public static Task<bool> ScaleTo(this VisualElement view, double scale, double anchorX, double anchorY, uint length = 250, Easing easing = null)
{
var tcs = new TaskCompletionSource<bool>();
if (easing == null)
{
easing = Easing.Linear;
}
new Animation(
(v) =>
{
view.Scale = scale;
view.AnchorX = anchorX;
view.AnchorY = anchorY;
}, 0, length
).Commit(view, nameof(view), 16, length, easing, finished: (f, a) => tcs.SetResult(a));
return tcs.Task;
}
You can implement pinch to zoom by using a pinch gesture recognizer.
Here is the documentation on pinch to zoom
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/gestures/pinch
At the same time if you want to add pan, you can combine the above code with
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/gestures/pan
Then you would have a pretty good full screen image viewer in Xamarin.Forms
You can use this library, just install on your .netstandard project and that's it!
You can then use Rg.Plugin.Popup and add the image dynamically by providing the link
xmlns:pinch="clr-namespace:Xamarin.Forms.PinchZoomImage;assembly=Xamarin.Forms.PinchZoomImage"
<pinch:PinchZoom.Content>
<Image Source="xxamarin.jpg" />
</pinch:PinchZoom.Content>
Messages such as CENTER_CHANGED on a web Browser HTML based google map get fired ok on desktop PC or laptop web browsers but on iPhones and iPads they never return the correct center coordinates when fored. Is there a way to do this?
No, you cannot.
not only for center_changed, but also drag, mousemove events, they all does not update bounds and center of the current map. it only updates when the move is done.
You can go around this in some complex way like this,
google.maps.event.addListener(map, 'dragstart', function(event) {
//save drag start bounds
//save mouse starting point
});
google.maps.event.addListener(map, 'drag', function(event) {
//get mouse moving distance
//calculate center from start bounds and mouse moving distance
});
google.maps.event.addListener(map, 'dragEnd', function(event) {
//save drag end bounds
});
I don't know your purpose of this. However, if it is to show markers dynamically, I would load all markers of 9 windows, which is the maximum of your center changing limit.
+--------+--------+--------+
: : : :
: : : :
+--------+========+--------+
: | view | :
: | port | :
+--------+========+--------+
: : : :
: : : :
+--------+--------+--------+