-
lance1994
For the collision I still had to set a player_hitbox Rect() for it to intersect with the rock , if you look above you'll see my rock code . I tried the
self.frame.intersects(item.frame)
But that doesn't work any idea guys?
-
lance1994
Okay Guys Something New Here Is The Code
class Rock(SpriteNode): def __init__(self, **kwargs): SpriteNode.__init__(self, 'IMG_1726.GIF', **kwargs) def update (self): self.spawn_rock class Rock(SpriteNode): def __init__(self, **kwargs): SpriteNode.__init__(self, 'IMG_1726.GIF', **kwargs)
It does what it's suppose to do spawn the rocks, but I want it to spawn 3 rocks at a time. After each rock is destroyed it is randomly generated somewhere else. Not immediately but like a 10 second duration. I tried if and else statements in the update but nothing seems to work , going to keep poking around any input ?
-
lance1994
Got everything up and running , it was a indention problem.
-
lance1994
Okay guys so everything works but now my touch movement for my Sprite isn't responding here's the original code before I implemented your code ,
x, _= touch.location _, y = self.player.position move_action = Action.move_to(x,y,2,TIMING_SINODIAL) self.player.run_action(move_action) if (x,_ > 0.05): self.player.x_scale = cmp(touch.location.x - self.player.position.x, 0) x = self.player.position.x
Do I switch it to self.sprite.position
Hmm
-
lance1994
Beautiful ccc I think I love you 😂 But for real thank you, you been a big help in my journey.
-
lance1994
I dont understand how ai would implement this into my game , but the concept is what I'm looking for being able to see my players/enemy hit box. but I want to implement this with out going thru ui , there has to be a easier way. 🤔 I'm currently trying many different options
-
-
lance1994
Is there a way I can make the Rect around my player a color for debugging purposes I'm fairly new , and I'm sure this is fairly simple but I tried fill_color, set_color nothing worked. Here is the code
player_hitbox = Rect(self.player.position.x - 20, 32, 40, 65,fill_color = "Blur")
-
-
lance1994
So here's the basic code for flipping it with gravity and abs :
def cmp (a, b):
return ((a> _b) - (a < b))g = gravity()
if abs(g.x) > 0.05:self.player.x_scale = cmp(g.x, 0)
This basically flips the image horizontally by tilting your device , but how do I go about getting it to flip with touch location. I've tried many variations , one variation I tried only got him to turn on the negative - axis but not the positive. any suggestions? Here is my player movement code btw:
x, _= touch.location
, y = self.player.position
move_action = Action.move_to(x,y,0.7,TIMING_SINODIAL)
self.player.run_action(move_action)
if (x, > 0.05):
self.player.x_scale = cmp(-x, 0)
x = self.player.position.x -
lance1994
So I got the basic , touch_began code I tried different variations but nothing seems to work, here is the code .
x,y = touch.location
move_action = Action.move_to(x,y, 0.7, TIMING_SINODIAL)
self.player.run_action(move_action)this is the code in the tutorial , this is not my example but how would I be able to switch this around to get the player to only move along the X , like I've said I've tried many variations but I'm quite new so a little help would go along way . Thanks 😘