Flash Game Design Notes: mouse games (3)

Source: Internet
Author: User

 

Flash Game Design Notes: mouse games (1)

Http://blog.csdn.net/hero82748274/archive/2009/02/11/3878304.aspx

 

 

Flash Game Design Notes: mouse games (2)

Http://blog.csdn.net/hero82748274/archive/2009/02/16/3897058.aspx

 

I. Force-sensing Production

Continue to modify the above file code and the data layer code. We return a desired data, so we use a simple response.

 

Private function getscale (): int <br/>{< br/> If (Power >=- 1) <br/>{// angle =-45; <br/> power + = math. tan (angle * 180/math. pi); <br/> If (power = 10) <br/>{< br/> angle =-135; <br/>}< br/> If (power = 0) <br/>{< br/> angle =-45; <br/>}< br/> return power; <br/>} 

 

The following describes how to simulate UI Press:

Private function addnum (Event: Event): void <br/>{< br/> var num: Int = getscale (); <br/> trace (Num ); <br/> mypower. scalex = num * 10; <br/>} 

 

Description: mypower is a video clip type movieclip. On the scene, I create a rectangular shape with a width of 1, named

Mypower: This is a simulation of inductive force. I set its scalsex range to 0,100]

 

Note: place the registration point on the left side of the rectangle. In this way, the rectangle can be moved to the right when it is scaled down,

Code List:

 

Package <br/> {<br/> Import flash. display. movieclip; <br/> Import flash. events. *; <br/> Import flash. text. textfield; <br/> Import flash. UI. mouse; <br/> public class example3 extends movieclip <br/> {<br/> private var DX: textfield; <br/> private var DY: textfield; <br/> private var photo: mousephoto; <br/> private var power: Int = 0; <br/> private var maxpower: Number = 100; <br/> private var angle: Int =-45; <br/> Public Function example3 () <br/>{< br/> addeventlistener (event. enter_frame, run); <br/> stage. addeventlistener (mouseevent. mouse_down, mousedown); <br/> stage. addeventlistener (mouseevent. mouse_up, mouseup); <br/> Init (); <br/>}< br/> private function Init (): void <br/>{< br/> dx = new textfield; <br/> addchild (dx); <br/> dx. width = 50; <br/> dx. height = 20; <br/> dx. X = 30; <br/> dx. y = 30; <br/> dx. border = true; <br/> DY = new textfield; <br/> addchild (dy); <br/> dy. width = 50; <br/> dy. height = 20; <br/> dy. X = 30; <br/> dy. y = 53; <br/> dy. border = true; <br/> mouse. hide (); // hide the mouse <br/> photo = new mousephoto; // create a map that replaces the mouse <br/> addchild (photo ); <br/>}< br/> private function run (Event: Event): void <br/>{< br/> dx. TEXT = string (mousex); <br/> dy. TEXT = string (Mousey); <br/> photo. X = mousex; <br/> photo. y = Mousey; <br/>}< br/> private function adds (): void <br/>{< br/> stage. addeventlistener (event. enter_frame, addnum); <br/>}</P> <p> private function addnum (Event: Event): void <br/>{< br/> var num: int = getscale (); <br/> trace (Num); <br/> mypower. scalex = num * 10; <br/>}</P> <p> private function getscale (): int <br/> {<br/> If (power> =-1) <br/> {// angle =-45; <br/> power + = math. tan (angle * 180/math. pi); <br/> If (power = 10) <br/>{< br/> angle =-135; <br/>}< br/> If (power = 0) <br/>{< br/> angle =-45; <br/>}< br/> return power; <br/>}</P> <p> private function mousedown (Event: mouseevent ): void <br/>{< br/> adds (); <br/>}</P> <p> private function mouseup (Event: mouseevent ): void <br/> {<br/> stage. removeeventlistener (event. enter_frame, addnum); <br/>}</P> <p >}< br/>} 

 

Expansion: we can also use a better UI to display an inductive force effect. With this effect, we can try to do more simulation.

In addition, the UI can be better implemented.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.