![]() ![]() The hardest part is just remembering the code. – SnapScene, SnapActor: Renamed MousePressed/KeyPressed methods to be MouseDown/KeyDown. This video demonstrates how to add sound to the collision detection with actors in Greenfoot 2.4.2. – SnapScene: Made playSound() check /sounds directory – SnapActor: Fixed setWidth/setHeight to preserve x/y – SnapPartStmt: Fixed dropNode on bottom of block statement – SnapScene: Made default scene have main() and act() methods – SnapAnimator: Fixed to animate X/Y instead of LayoutX/Y – SnapActor: Fixed to have X/Y be at center of actor – SnapScene: Fixed KeyDown to be a Set of Ke圜odes instead of just one – SnapActor: Added getIntersectingActor/getIntersectingActors Below is the full list of improvements made to SnapCode this week. Additionally, we updated the KeyDown and Ke圜licked functionality to handle multiple down/clicked keys at once – because it turns out that real gameplay often involves this (head-smack).Įarly next week I’ll release our test case – a JavaFX/SnapCode version of asteroids. You need the sound file in the sounds folder of the scenario - I will call it 'click.wav': aySound('click. This makes it possible to determine whether a given actor overlaps (or “hit”) another actor and will be useful for most games. You need the sound file in the sounds folder of the scenario - I will call it 'click.wav': aySound('click.wav') Archimedes007. This week added some hit detection methods to the SnapActor class: – SnapScene: Made this a subclass of SnapParent so it gets same Actor/Image management – SnapParent: Created Actor subclass that can have child actors – SnapImage: Added fillRoundRect, strokeLine, strokeRect, strokeRoundRect – SnapImage: Added getColor(int,int) and setColor(int,int,color) – SnapImage: Added flipImageX/flipImageY/rotateImage() to get current image in new orientation ![]() – SnapImage: Added class to add rendering and drawing functionality to Actors Here is a full list of the week’s changes: ![]() Since this essentially what SnapScene does, I made SnapScene a SnapParent subclass to get more consistency and code re-use. This class is called SnapParent, and it basically has a list attribute called Actors that lets you add/remove child actors, and it has methods to do hit detection on those child actors and/or retrieve subsets of the actors by class. World nextWorld new Level2World () // or whatever nextWorld.addObject (actor, 50, 50) // choose appropriate coordinates tWorld (nextWorld) There are some variations on this, but this is basically the idea. SnapActor now has a primary attribute that is a SnapImage, so you can easily create actors with custom drawing and you can easily change the look of an actor on the fly by resetting or manipulating the SnapActor.Image.Īdditionally, I added a new SnapActor subclass to make it possible to have compound or nested actors. Then, after you create the new world, you can just add the actor to it in the usual way. The class is called SnapImage and it has methods to load an image from a file name, and methods to do all kinds of drawing and basic image manipulation: flipImage, rotateImage, sizeImage, setColor (for a pixel), etc. This week I added a class to SnapCode to facilitate “sprite” programming with SnapActor. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |