Monday, 15 June 2015

android - math.random image re-appearing off screen -



android - math.random image re-appearing off screen -

having little issue collision , math.random sending images off screen.

so have ball hits brick , brick randomly re-locate, brick image keeps going off screen. brick rotated 90 degrees i'm not sure if effects anything. there 61px tall image @ top of screen image keeps re-locating behind , thinking - 61 added help, haven't had luck.

xrandom = math.random(display.contentwidth - brick.width) yrandom = math.random(display.contentheight - brick.height) transition.to(brick, {delay = 200, x = xrandom, y= yrandom , time=0})

as have it, xrandom between 1 , display.contentwidth - brick.width: if anchor point of brick x=0, ensures brick can't positioned far right. perhaps x anchor not @ 0, or anchor x=0 not correspond left side of image (perhaps way loaded? can't tell without seeing code).

same goes y coordinate: 0 @ top of screen , increases downward. yrandom between 1 , display.contentheight - brick.height ensure brick visible if y anchor @ y=0 , anchor top of image.

if have image @ top of screen, should limit smallest y larger image's height, ie utilize yrandom = math.random(topimageheight, display.contentheight - brick.height).

it impossible tell if part of problem due rotation without seeing code. if can post minimal illustration can run create lot easier provide more accurate answer.

android lua corona

No comments:

Post a Comment