How to move a created actor in the direction of specific point in screen !

Yob Games

  • Posts: 20
i want to move my spawnedd actor  in the direction oof a point defined by me  ( look at the image )
pleaze tell me all what  i have to do beacause i'm neww with stencyl


merrak

  • *
  • Posts: 2540
A simple approach would be to put the following in an 'always' event for the moving actors:

Code: [Select]
If x of self < x of target then
   set x of self to ( x of self ) + 1
else if x of self > x of target then
   set x of self to ( x of self ) - 1

if y of self < y of target then
   set y of self to ( y of self ) + 1
else if y of self > y of target then
   set y of self to ( y of self ) - 1

x of target and y of target can be number attributes that you set

That isn't a great script, but it ought to get you started. Once you have the basic mechanics working, you can think about  how to handle special circumstances.

Yob Games

  • Posts: 20
Thaankkk'ssss itt'ss workiinng