positioning image sprite in canvas

69 views
Skip to first unread message
Assigned to scottfr...@gmail.com by taifu...@gmail.com

ferhan2...@gmail.com

unread,
Jun 5, 2014, 3:56:17 PM6/5/14
to mitappinv...@googlegroups.com
I have the AlignHorizontal of my screen set to "Center". The width of my canvas is set to "screen width + 10" (adds extra 5 pixels to both sides of the screen which won't be visible). I have an image sprite in my canvas with a width of "screen width". I've set the x position of my image sprite to "5" since setting it to "0" will shift it to the left side of the screen. But when i run it on my mobile, the x position of my image spirte is still stuck at 0. How can i fix this??? It shouldn't be that complicated...the coding is pretty straightforward. 

Taifun

unread,
Jun 5, 2014, 4:04:46 PM6/5/14
to mitappinv...@googlegroups.com
probably this is a timing issue?
my suggestion is to use a clock component and set the image sprite in the Clock.Timer event just a little bit later at position x=5

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

ferhan2...@gmail.com

unread,
Jun 5, 2014, 8:44:20 PM6/5/14
to mitappinv...@googlegroups.com
I don't understand why I would need a clock component when I'm not dealing with any animation at the moment. But here is a screenshot of my relevant blocks. They are really simple and straightforward.
appinventor.jpg

Enis

unread,
Jun 5, 2014, 10:33:58 PM6/5/14
to mitappinv...@googlegroups.com
You need to show us the blocks where you're dealing with the sprite and it's positioning...

Scott Ferguson

unread,
Jun 5, 2014, 10:51:21 PM6/5/14
to mitappinv...@googlegroups.com
This may be similar to the problem that I was having with a Canvas that was 1440 pixels wide.
(You cannot set canvas width larger than 999 in the Designer)
I had to set the width to 1440 in the screen Initialize block, then start a timer which checked if the canvas had changed to the desired width.
Once it had resized, the app continued execution of other blocks.
So you might set the x value to 5 then start a timer to wait for the x value to change to 5.
Just something to try.
---
Scott
Reply all
Reply to author
Forward
0 new messages