ios7 - Sprite kit ios game slingshot machanism similar to angry bird game -
i newbie in ios gaming, , need create game using sprite kit framework functionality similar angry bird pulley system, , wants find distance object travelled pulley landing.
can me out this, thankfull it. in advance.
one way code slingshot effect use starting point on screen @ let's (x=100,y=100). display spritenode of slingshot y centered @ (100,100).
the next step use touchesbegan:withevent:
in area of slingshot let code know player looking shoot slingshot.
you use touchesmoved:withevent:
track how far (how tension) player pulling slingshot.
the release triggtouchesended:withevent
. based on how far touch began (x=100) , how far released (for example x=30), can apply force this:
float forceused = starttouchx - endtouchx; [_projectile.physicsbody applyforce:cgvectormake(forceused, 0)];
if looking angle shot have track y , use variable instead of 0 above.
as calculating distance between 2 points on screen, boils down x , y coordinates. subtract objecta.position.x objectb.position.x
things can lot more complex of course depends on want in code. hope helps.
p.s. touches above part of uiresponder class
.
Comments
Post a Comment