Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Rotating ImageView 360 degrees [Alloy]

$
0
0

Hi,

I'm trying to rotate imageviews 360 degrees for an infinite amount of time(creating 15 of them on opening of a window), now I have found that this is not so simple on iOS(limitations..) and I have found a source for doing this. The downside is that I can not get this for an infinite amount of time and it only rotates 1 imageview and not all.

The code I have works perfectly on android. The code from the module does not have what I want to rotate imageviews on iOS

My current code:

if (Ti.Platform.name == 'android') {
        for ( i = 0; i <= 14; i++) {
 
            var question = Ti.UI.createImageView({
                anchorPoint : {
                    x : 0.5,
                    y : 0.5
                }
            });
 
            var matrix2d = Ti.UI.create2DMatrix();
            matrix2d = matrix2d.rotate(360);
 
            var a = Ti.UI.createAnimation({
                transform : matrix2d,
                duration : 2000,
                autoreverse : false,
                repeat : 10000
            });
 
            question.image = '/images/test.jpeg';
            question.width = 30;
            question.height = 30;
            question.left = generateRandomNumber();
            question.top = generateRandomNumber();
 
            $.main.add(question);
            question.animate(a);
 
        }
    } else {
        for ( i = 0; i <= 14; i++) {
 
            var my_module = require('path.animator');
            var foo = my_module.createView({
                width : 30,
                height : 30,
                top : generateRandomNumber(),
                left : generateRandomNumber()
            });
 
            var image = Ti.UI.createImageView({
                image : '/images/test.jpeg',
                width : 30,
                height : 30
            });
            foo.add(image);
 
            foo.addEventListener('click', function() {
                foo.rotate({
                    angle: 360,
                    duration: 2000,
                    delay: 1,
                    timingFunction: Ti.UI.ANIMATION_CURVE_EASE_OUT
                });
            });
 
            $.main.add(foo);
 
        }
    }

Is there a solution to get all imageviews on the screen rotating 360 degrees for an infinite amount of time?


Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>