|
Prev: director LoadMovie
Next: Flash Variable with FileXtra4
From: m_saade on 4 May 2008 17:58 thx for the remark.. i got it working now. but i still need the code for the random thing i mentioned above if someone can help.
From: multiduck on 4 May 2008 19:39 This should work for you if I understood you correctly. property pAnimDir property pMoving property pSpriteNum on beginsprite me pSpriteNum=me.spritenum pMoving=false end on mouseenter me if pMoving=false then tDir=random(2) if tDir=1 then pAnimDir="left" else pAnimDir="right" end if pMoving=true end if end on mouseleave me pMoving=false end on enterframe me if pMoving=true then tPosX=Sprite(pSpriteNum).loch if tPosX <= 50 then pAnimDir="right" end if if tPosX >= 459 then pAnimDir="left" end if if pAnimDir="left" then Sprite(pSpriteNum).loch = tPosX - 5 else Sprite(pSpriteNum).loch = tPosX + 5 end if end if end on exitframe me go to the frame end
From: m_saade on 5 May 2008 10:28 i need the random animation for a new sprite, its not related to the anim="left" ... what i need is the code to make a sprite on mouseenter, disappear and appear in a random place within the 500*500 stage. and josh i check the websites.. they are useful but i need an ebook or a website where i can get lessons and examples in lingo, starting from the basics.. for i need help to make a game as a university project, and the codes i learned are very basic.
From: multiduck on 5 May 2008 13:11 Ah, you can still use most of the same code tho. And here is a free ebook about game programming with director http://garyrosenzweig.com/advancedlingoforgames/ it used to be in print so if you like it support the author by buying his other book, details on the linked page. on mouseenter me tSpr=me.spritenum -- get size of movie stage tStageWidth=_movie.stage.rect.right-_movie.stage.rect.left tStageHeight=_movie.stage.rect.bottom-_movie.stage.rect.top -- assuming that the spirtes registraion point is at the center of the sprite tSW=sprite(tSpr).width -- get size of sprite tSH=sprite(tSpr).height -- and the height tXmax=tStageWidth-tSW -- get highest value we want for loch (=> stage - sprite size) tYmax=tStageHeight-tSH -- and locv tX=random(tXmax)+(tSW*0.5) -- get a random position + half the width of the sprite so that the spite appears within the borders of the stage tY=random(tYmax)+(tSH*0.5) sprite(tSpr).loc=point(tX, tY) -- move sprite end
From: m_saade on 5 May 2008 16:03 thank u alot for ur help.. i really appreciate it regards
|
Pages: 1 Prev: director LoadMovie Next: Flash Variable with FileXtra4 |