shivalingesh nashipur this.unschedule(bullets);
Posts 19
Added by shivalingesh nashipur about 1 year ago

this.schedule(bullets,0.3f);

public void bullets(float interval) {
throwprojectile(new CCPoint(820, 240));
}

public override void ccTouchesEnded(List<CCTouch> touches, CCEvent event_) {
if(touches.Count>0) {
this.unschedule(bullets); // ???????????????????????????????????????????????????????????????????????????
CCTouch loc = touches.ElementAt(0);
touches.Clear();
CCPoint location = loc.locationInView(loc.view());
location = CCDirector.sharedDirector().convertToGL(location);
// Determine offset of location to projectile
float offX =location.x - 20;
float offY = location.y -240;
// Bail out if we are shooting down or backwards
if (offX <= 0) return;
//ok to add projectile here now
// Determine where we wish to shoot the projectile to
float realX = size.width +10;
float ratio = offY / offX;
float realY = (realX * ratio) + 240;
CCPoint realDest = new CCPoint(realX, realY);
throwprojectile(realDest);
// Determine the length of how far we're shooting
// Move projectile to actual endpoint
/* [projectile runAction:[CCSequence actions:[CCMoveTo actionWithDuration:realMoveDuration position:realDest],
[CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)],nil]];*/
touches.Clear();
}
base.ccTouchesEnded(touches, event_);
}

public void throwprojectile(CCPoint realDest) {

float realMoveDuration;
CCSprite projectile = CCSprite.spriteWithFile(@"images\projectile", new CCRect(0, 0, 20, 20));
projectile.position = new CCPoint(20, size.height / 2);
this.addChild(projectile);
float offRealX = 820 - projectile.position.x;
float offRealY = 240 - projectile.position.y;
float length = (float)Math.Sqrt((offRealX * offRealX) + (offRealY * offRealY));
float velocity = 480 / 1; // 480pixels/1sec
realMoveDuration = length / velocity;
projectile.runAction(CCSequence.actions(CCMoveTo.actionWithDuration(realMoveDuration, realDest), CCCallFuncN.actionWithTarget(projectile, spritemovefinished)));
this.resumeSchedulerAndActions(); //???????????????????????????????????????????????????????????????????????????????????????????????????????????????????? what to put here
}

I am tryng to throw bullets at sheduler and whenever user clicks on screen i did changed the target destination once again i want to shoot at default when user doesnt clicks ???

shivalingesh nashipur RE: this.unschedule(bullets);
Posts 19
Added by shivalingesh nashipur about 1 year ago

Right now i used some flags, and its working,, but how to pause and resume shedule????????

Jacob Anderson RE: this.unschedule(bullets);
Posts 178
Location Totally Evil Entertainment - San Diego
Added by Jacob Anderson 9 months ago

I know this is a very old post, but did you see:

CCScheduler.sharedScheduler().pauseTarget(this);

This will allow you to pause and resume the scheduler on your target.

Raghu S RE: this.unschedule(bullets);
Posts 74
Added by Raghu S 9 months ago

He's not working on this anymore.. but thanks for the reply.

Jacob Anderson RE: this.unschedule(bullets);
Posts 178
Location Totally Evil Entertainment - San Diego
Added by Jacob Anderson 9 months ago

hi Raghu,

I noticed someone posted a question about Box2d and cocos2d-xna. Are you using The Bullet XNA API or some other xna-bullet-type API? i am wondering if I need to port box2d or just add support for bullet and other bullet-type APIs?

-- jake

Raghu S RE: this.unschedule(bullets);
Posts 74
Added by Raghu S 9 months ago

Hi Jake,

No I have not used Bullet XNA yet. It would be very cool to have this. It is better to ask other Dev's about their interest to have this in cocos-xna.

regards,
Raghu


(1-5/5)